當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。