當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


JavaScript ArcGIS config.LogInterceptor用法及代碼示例

基本信息

以下是所在類或對象的基本信息。

AMD: require(["esri/config"], (esriConfig) => { /* code goes here */ });

ESM: import esriConfig from "@arcgis/core/config";

對象: esri/config

自從:用於 JavaScript 4.0 的 ArcGIS API

用法說明

config.LogInterceptor函數(或屬性)的定義如下:

LogInterceptor (level, module, args) {Boolean}


自定義日誌攔截器函數。

參數:

類型說明
level String

消息的級別。

可能的值"error"|"warn"|"info"

module String

生成日誌消息的模塊。

args *
可重複的

要記錄的任何類型的參數。

返回:

類型 說明
Boolean 返回 true 表示日誌消息已被處理並且不應再被處理(既不被其他攔截器也不被將消息記錄到控製台的默認處理程序)。

例子:

// Only show error messages, not warnings nor info messages
esriConfig.log.level = "error";

esriConfig.log.interceptors.push(function(level, module, ...args) {
  // Send all messages to a REST end-point
  request(loggingUrl, {
    method: "post",
    body: {
            level: level,
            module: module,
            details: JSON.stringify(args)
          }
  });

  // Return false so that the default log handler still writes log messages to the console
  return false;
});

相關用法


注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 config.LogInterceptor。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。