log(日誌)

在 Eagle 軟體日誌記錄特定資訊,以利開發中的除錯、除錯。

點擊這裏查看 Eagle 軟體日誌獲取方式。

eagle.log.debug('debug message from plugin');
eagle.log.info('info message from plugin');
eagle.log.warn('warn message from plugin');
eagle.log.error('error message from plugin');

// [13:19:39.845] [debug] [plugin] "debug message from plugin"
// [13:19:39.845] [info] [plugin] "info message from plugin"
// [13:19:39.845] [warn] [plugin] "warn message from plugin"
// [13:19:39.845] [error] [plugin] "error message from plugin"

方法

debug(obj)

記錄 debug 類型內容到軟體日誌

  • obj Object - 欲記錄之內容,可以是 ObjectStringArray 等各種格式

eagle.log.debug(obj);
eagle.log.debug(array);
eagle.log.debug('error message from plugin');

info(obj)

記錄 info 類型內容到軟體日誌

  • obj Object - 欲記錄之內容,可以是 ObjectStringArray 等各種格式


warn(obj)

記錄 warn 類型內容到軟體日誌

  • obj Object - 欲記錄之內容,可以是 ObjectStringArray 等各種格式


error(obj)

記錄 error 類型內容到軟體日誌

  • obj Object - 欲記錄之內容,可以是 ObjectStringArray 等各種格式

try {
    let a = {};
    a.b.c = 'test';
}
catch (err) {
    eagle.log.error('error message from plugin');
    eagle.log.error(err.stack || err);
}

// [13:23:24.191] [error] [plugin] "error message from plugin"
// [13:23:24.191] [error] [plugin] "TypeError: Cannot set properties of undefined (setting 'c')\n    at <anonymous>:3:11"

最后更新于