本文整理汇总了Java中com.bugsnag.callbacks.Callback类的典型用法代码示例。如果您正苦于以下问题:Java Callback类的具体用法?Java Callback怎么用?Java Callback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Callback类属于com.bugsnag.callbacks包,在下文中一共展示了Callback类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bugsnagClient
import com.bugsnag.callbacks.Callback; //导入依赖的package包/类
public static Bugsnag bugsnagClient(OkHttpClient client, String platform, String version, final String serverVersion,
final Supplier<ServerInformation> serverInformation) {
Bugsnag bugsnag = new Bugsnag("cac4ea0fdbe89b5004d8ab8d5409e594", false);
bugsnag.setDelivery(new OkHttpBugsnagDelivery(client));
bugsnag.setAppVersion(version);
bugsnag.setProjectPackages("net.buycraft.plugin");
bugsnag.addCallback(new BuycraftBeforeNotify());
bugsnag.setAppType(platform);
bugsnag.addCallback(new Callback() {
@Override
public void beforeNotify(Report report) {
report.setAppInfo("serverVersion", serverVersion);
ServerInformation information = serverInformation.get();
if (information != null) {
report.addToTab("user", "account_id", information.getAccount().getId());
report.addToTab("user", "server_id", information.getServer().getId());
}
}
});
return bugsnag;
}
示例2: disableBugsnag
import com.bugsnag.callbacks.Callback; //导入依赖的package包/类
private void disableBugsnag() {
this.bugsnag.addCallback(new Callback() {
@Override
public void beforeNotify(Report report) {
report.cancel();
}
});
}
示例3: enableBugsnag
import com.bugsnag.callbacks.Callback; //导入依赖的package包/类
private void enableBugsnag() {
this.bugsnag.addCallback(new Callback() {
@Override
public void beforeNotify(Report report) {
Boolean shouldBeSent = false;
for (StackTraceElement stackTraceElement : report.getException().getStackTrace()) {
if (stackTraceElement.toString().contains("io.github.bedwarsrel.BedwarsRel")) {
shouldBeSent = true;
break;
}
}
if (!shouldBeSent) {
report.cancel();
}
report.setUserId(SupportData.getIdentifier());
if (!SupportData.getPluginVersionBuild().equalsIgnoreCase("unknown")) {
report.addToTab("Server", "Version Build",
BedwarsRel.getInstance().getDescription().getVersion() + " "
+ SupportData.getPluginVersionBuild());
}
report.addToTab("Server", "Version", SupportData.getServerVersion());
report.addToTab("Server", "Version Bukkit", SupportData.getBukkitVersion());
report.addToTab("Server", "Server Mode", SupportData.getServerMode());
report.addToTab("Server", "Plugins", SupportData.getPlugins());
}
});
}
示例4: notify
import com.bugsnag.callbacks.Callback; //导入依赖的package包/类
/**
* Notify Bugsnag of a handled exception.
*
* @param throwable the exception to send to Bugsnag
* @param severity the severity of the error, one of {#link Severity#ERROR},
* {@link Severity#WARNING} or {@link Severity#INFO}
* @param callback the {@link Callback} object to run for this Report
* @return true unless the error report was ignored
*/
public boolean notify(Throwable throwable, Severity severity, Callback callback) {
if (throwable == null) {
LOGGER.warn("Tried to notify with a null Throwable");
return false;
}
HandledState handledState = HandledState.newInstance(
HandledState.SeverityReasonType.REASON_USER_SPECIFIED, severity);
Report report = new Report(config, throwable, handledState);
return notify(report, callback);
}
示例5: testCallbackCancel
import com.bugsnag.callbacks.Callback; //导入依赖的package包/类
@Test
public void testCallbackCancel() {
Bugsnag bugsnag = new Bugsnag("apikey");
bugsnag.setDelivery(BugsnagTestUtils.generateDelivery());
bugsnag.addCallback(new Callback() {
@Override
public void beforeNotify(Report report) {
report.cancel();
}
});
// Test the report is not sent
assertFalse(bugsnag.notify(new Throwable()));
}
示例6: addCallback
import com.bugsnag.callbacks.Callback; //导入依赖的package包/类
void addCallback(Callback callback) {
callbacks.add(callback);
}
示例7: addCallback
import com.bugsnag.callbacks.Callback; //导入依赖的package包/类
/**
* Add a callback to execute code before/after every notification to Bugsnag.
*
* <p>You can use this to add or modify information attached to an error
* before it is sent to your dashboard. You can also stop any reports being
* sent to Bugsnag completely.
*
* @param callback a callback to run before sending errors to Bugsnag
* @see Callback
*/
public void addCallback(Callback callback) {
config.addCallback(callback);
}