当前位置: 首页>>代码示例>>Java>>正文


Java Callback类代码示例

本文整理汇总了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;
}
 
开发者ID:BuycraftPlugin,项目名称:BuycraftX,代码行数:22,代码来源:Setup.java

示例2: disableBugsnag

import com.bugsnag.callbacks.Callback; //导入依赖的package包/类
private void disableBugsnag() {
  this.bugsnag.addCallback(new Callback() {
    @Override
    public void beforeNotify(Report report) {
      report.cancel();
    }
  });
}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:9,代码来源:BedwarsRel.java

示例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());
    }
  });
}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:29,代码来源:BedwarsRel.java

示例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);
}
 
开发者ID:bugsnag,项目名称:bugsnag-java,代码行数:21,代码来源:Bugsnag.java

示例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()));
}
 
开发者ID:bugsnag,项目名称:bugsnag-java,代码行数:14,代码来源:BugsnagTest.java

示例6: addCallback

import com.bugsnag.callbacks.Callback; //导入依赖的package包/类
void addCallback(Callback callback) {
    callbacks.add(callback);
}
 
开发者ID:bugsnag,项目名称:bugsnag-java,代码行数:4,代码来源:Configuration.java

示例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);
}
 
开发者ID:bugsnag,项目名称:bugsnag-java,代码行数:14,代码来源:Bugsnag.java


注:本文中的com.bugsnag.callbacks.Callback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。