Skip to content

Commit

Permalink
docs(schedule): logging && args (#2091)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored and dead-horse committed Feb 8, 2018
1 parent 03a8944 commit 5621a85
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
18 changes: 16 additions & 2 deletions docs/source/en/basics/schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ In addition to the parameters just introduced, scheduled task also supports thes
- `immediate`: when this parameter is set to true, this scheduled task will be executed immediately after the application is started and ready.
- `disable`: when this parameter is set to true, this scheduled task will not be executed.

### Logging

Schedule log will write to `${appInfo.root}/logs/egg-schedule.log`, but don't log to terminal by default, you could custom by config `config.customLogger.scheduleLogger`.

```js
// config/config.default.js
config.customLogger = {
scheduleLogger: {
consoleLevel: 'NONE',
file: path.join(appInfo.root, 'logs', appInfo.name, 'egg-schedule.log'),
},
};
```

### Dynamically Configure Scheduled Tasks

Sometimes we need to determine the different environment to configure the parameters of scheduled tasks. Scheduled tasks support another development style:
Expand Down Expand Up @@ -203,5 +217,5 @@ module.exports = agent => {
`ScheduleStrategy` base class provides:

- `schedule` - Properties of schedule tasks, `disable` is supported by default, other configurations can be parsed by developers.
- `this.sendOne()` - Notice worker to execute the task randomly.
- `this.sendAll()` - Notice all worker to execute the task.
- `this.sendOne(...args)` - Notice worker to execute the task randomly, `args` will pass to `subscribe(...args)` or `task(ctx, ...args)`.
- `this.sendAll(...args)` - Notice all worker to execute the task.
18 changes: 16 additions & 2 deletions docs/source/zh-cn/basics/schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ module.exports = {
- `immediate`:配置了该参数为 true 时,这个定时任务会在应用启动并 ready 后立刻执行一次这个定时任务。
- `disable`:配置该参数为 true 时,这个定时任务不会被启动。

### 执行日志

执行日志会输出到 `${appInfo.root}/logs/egg-schedule.log`,默认不会输出到控制台,可以通过 `config.customLogger.scheduleLogger` 来自定义。

```js
// config/config.default.js
config.customLogger = {
scheduleLogger: {
consoleLevel: 'NONE',
file: path.join(appInfo.root, 'logs', appInfo.name, 'egg-schedule.log'),
},
};
```

### 动态配置定时任务

有时候我们需要判断不同的环境来配置定时任务的参数。定时任务还有支持另一种写法:
Expand Down Expand Up @@ -203,5 +217,5 @@ module.exports = agent => {
`ScheduleStrategy` 基类提供了:

- `schedule` - 定时任务的属性,`disable` 是默认统一支持的,其他配置可以自行解析。
- `this.sendOne()` - 随机通知一个 worker 执行 task。
- `this.sendAll()` - 通知所有的 worker 执行 task。
- `this.sendOne(...args)` - 随机通知一个 worker 执行 task`args` 会传递给 `subscribe(...args)``task(ctx, ...args)`
- `this.sendAll(...args)` - 通知所有的 worker 执行 task。

0 comments on commit 5621a85

Please sign in to comment.