系统设置增加系统运行日志

This commit is contained in:
whyour
2023-08-21 00:10:43 +08:00
parent b002cbef3a
commit 4f7649f157
33 changed files with 864 additions and 112 deletions
+9 -9
View File
@@ -66,7 +66,7 @@ export default class ScheduleService {
cp.stderr.on('data', async (data) => {
this.logger.info(
'[执行任务失败] %s,时间:%s, 错误信息%j',
'[执行任务失败] %s, 时间: %s, 错误信息: %j',
command,
new Date().toLocaleString(),
data.toString(),
@@ -76,7 +76,7 @@ export default class ScheduleService {
cp.on('error', async (err) => {
this.logger.error(
'[创建任务失败] %s,时间:%s, 错误信息%j',
'[创建任务失败] %s, 时间: %s, 错误信息: %j',
command,
new Date().toLocaleString(),
err,
@@ -86,7 +86,7 @@ export default class ScheduleService {
cp.on('exit', async (code, signal) => {
this.logger.info(
`[任务退出] ${command} 进程id: ${cp.pid}退出码 ${code}`,
`[任务退出] ${command} 进程id: ${cp.pid}, 退出码 ${code}`,
);
});
@@ -101,7 +101,7 @@ export default class ScheduleService {
});
} catch (error) {
await this.logger.error(
'执行任务%s失败,时间:%s, 错误信息%j',
'[执行任务失败] 命令: %s, 时间: %s, 错误信息: %j',
command,
new Date().toLocaleString(),
error,
@@ -119,7 +119,7 @@ export default class ScheduleService {
) {
const _id = this.formatId(id);
this.logger.info(
'[创建cron任务]任务ID: %scron: %s任务名: %s执行命令: %s',
'[创建cron任务], 任务ID: %s, cron: %s, 任务名: %s, 执行命令: %s',
_id,
schedule,
name,
@@ -140,7 +140,7 @@ export default class ScheduleService {
async cancelCronTask({ id = 0, name }: ScheduleTaskType) {
const _id = this.formatId(id);
this.logger.info('[取消定时任务]任务名%s', name);
this.logger.info('[取消定时任务], 任务名: %s', name);
if (this.scheduleStacks.has(_id)) {
this.scheduleStacks.get(_id)?.cancel();
this.scheduleStacks.delete(_id);
@@ -155,7 +155,7 @@ export default class ScheduleService {
) {
const _id = this.formatId(id);
this.logger.info(
'[创建interval任务]任务ID: %s任务名: %s执行命令: %s',
'[创建interval任务], 任务ID: %s, 任务名: %s, 执行命令: %s',
_id,
name,
command,
@@ -167,7 +167,7 @@ export default class ScheduleService {
},
(err) => {
this.logger.error(
'执行任务%s失败,时间:%s, 错误信息%j',
'[执行任务失败] 命令: %s, 时间: %s, 错误信息: %j',
command,
new Date().toLocaleString(),
err,
@@ -190,7 +190,7 @@ export default class ScheduleService {
async cancelIntervalTask({ id = 0, name }: ScheduleTaskType) {
const _id = this.formatId(id);
this.logger.info('[取消interval任务]任务ID: %s任务名%s', _id, name);
this.logger.info('[取消interval任务], 任务ID: %s, 任务名: %s', _id, name);
this.intervalSchedule.removeById(_id);
}