Squash Client Library: Java
===========================
This client library reports exceptions to Squash, the Squarish exception
reporting and management system.
Documentation
-------------
For an overview of the various components of Squash, see the website
documentation at https://github.com/SquareSquash/web.
Compatibility
-------------
This library is compatible with J2SE 1.6 or newer. All dependencies are handled
by Maven.
Usage
-----
The `SquashEntry` class is meant to be extended and then serialized with your
choice of json library for transmission to your Squash server. We recommend
using gson, but any auto-field-name-detecting library will do.
First, extend `SquashEntry` and include any additional occurrence data you wish
to send to Squash. See the `Occurrence` class documentation in the Squash web
code for a list of known properties; you can also supply any arbitrary
properties as well.
```` java
import com.squareup.squash.SquashEntry;
public class AndroidSquashEntry extends SquashEntry implements LogEntry {
// The API key used for all Android Squash entries.
private static final String API_KEY = "YOUR_API_KEY";
private static final String CLIENT_ID = "android";
private static final String DEBUG = "Debug";
private static final String RELEASE = "Release";
// Transient so it doesn't try to serialize itself.
private transient Gson gson;
// Device stuff.
private final String device_id;
private final String device_type;
private final String operating_system;
private final boolean rooted;
private final String network_operator;
private final String network_type;
private final String connectivity;
private final String orientation;
// Location stuff.
private final String lat;
private final String lon;
private final String altitude;
private final String location_precision;
private final String heading;
private final String speed;
// Which app am I?
private final String app_id;
}
````
Build a constructor or whatever you need to set all these parameters, and then
add the ability for the class to transmit itself to Squash:
```` java
public class AndroidSquashEntry extends SquashEntry implements LogEntry {
@Override public void writeTo(OutputStream output) throws IOException {
final String json = gson.toJson(this);
output.write(Strings.getBytes(json));
}
}
````
Add an exception handler that will generate these entry instances. (In the below
example we're assuming that you've also built a factory that instantiates Squash
entries, and a `transmit` method that transmits the JSON to Squash.)
```` java
public class SquashUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
@Inject AndroidSquashEntryFactory squashEntryFactory;
@Override public void uncaughtException(Thread thread, Throwable ex) {
try {
transmit(squashEntryFactory.create(message, ex));
} catch (Throwable ignored) {
// write your internal failsafe handler
}
}
}
````
... and install the exception handler.
```` java
final Thread.UncaughtExceptionHandler handler =
Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(
new SquashUncaughtExceptionHandler(this, handler));
````
De-Obfuscation and File Paths
-----------------------------
The [Squash Java Deobfuscator](https://github.com/SquareSquash/java_deobfuscator)
Ruby gem can be included into your build-and-release process to upload yGuard
or ProGuard obfuscation maps to Squash.
Even if you are not using code obfuscation, you can still use this gem to map
Java class names to their original file paths, as Java stack traces do not
include the full path to source files, which Squash needs to perform its
Git-blame magic.
没有合适的资源?快使用搜索试试~ 我知道了~
免费开源!!Java 项目的 Squash 客户端库
共8个文件
java:3个
xml:2个
gitignore:1个
需积分: 5 0 下载量 30 浏览量
2023-11-08
10:39:54
上传
评论
收藏 16KB ZIP 举报
温馨提示
Squash 客户端库:Java 该客户端库向 Squash(Squarish 异常报告和管理系统)报告异常。 文档 有关 Squash 各个组件的概述,请参阅网站文档https://github.com/SquareSquash/web。 兼容性 该库与 J2SE 1.6 或更高版本兼容。所有依赖项均由 Maven 处理。 用法 该类SquashEntry旨在扩展,然后使用您选择的 json 库进行序列化,以便传输到您的 Squash 服务器。我们建议使用 gson,但任何自动字段名称检测库都可以。 首先,扩展SquashEntry并包含您希望发送到 Squash 的任何其他事件数据。有关已知属性的列表,请参阅OccurrenceSquash Web 代码中的类文档;您还可以提供任意属性。
资源推荐
资源详情
资源评论
收起资源包目录
java-master (9).zip (8个子文件)
java-master
checkstyle.xml 5KB
pom.xml 3KB
LICENSE.txt 11KB
src
test
java
com
squareup
squash
SquashEntryTest.java 14KB
main
java
com
squareup
squash
SquashBacktrace.java 5KB
SquashEntry.java 3KB
.gitignore 18B
README.md 4KB
共 8 条
- 1
资源评论
技术小羊
- 粉丝: 811
- 资源: 114
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功