# log（日誌）

{% hint style="info" %}
點擊這裏查看 Eagle [軟體日誌](https://docs-cn.eagle.cool/article/92-how-do-i-get-the-error-log)取得方式。
{% endhint %}

```javascript
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"
```

***

#### 方法 <a href="#z1a5y" id="z1a5y"></a>

## debug(obj) <a href="#haugb" id="haugb"></a>

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

* `obj` Object - 欲記錄之內容，可以是 `Object`、`String`、`Array` 等各種格式

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

***

## info(obj) <a href="#qxf3f" id="qxf3f"></a>

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

* `obj` Object - 欲記錄之內容，可以是 `Object`、`String`、`Array` 等各種格式

***

## warn(obj) <a href="#ctpju" id="ctpju"></a>

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

* `obj` Object - 欲記錄之內容，可以是 `Object`、`String`、`Array` 等各種格式

***

## error(obj) <a href="#mo6j1" id="mo6j1"></a>

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

* `obj` Object - 欲記錄之內容，可以是 `Object`、`String`、`Array` 等各種格式

```javascript
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"
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.eagle.cool/plugin-api/zh-tw/api/log.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
