修改系统日志时间打印

This commit is contained in:
whyour 2023-08-26 20:51:17 +08:00
parent b4e4e84bbd
commit 648b9c4520
5 changed files with 8 additions and 21 deletions

View File

@ -33,9 +33,7 @@ const addCron = (
id, id,
nodeSchedule.scheduleJob(id, schedule, async () => { nodeSchedule.scheduleJob(id, schedule, async () => {
Logger.info( Logger.info(
`[schedule][准备运行任务] 时间: ${dayjs().format( `[schedule][准备运行任务] 命令: ${cmdStr}`,
'YYYY-MM-DD HH:mm:ss',
)}运行命令: ${cmdStr}`,
); );
runCron(`ID=${id} ${cmdStr}`); runCron(`ID=${id} ${cmdStr}`);
}), }),

View File

@ -66,9 +66,8 @@ export default class ScheduleService {
cp.stderr.on('data', async (data) => { cp.stderr.on('data', async (data) => {
this.logger.info( this.logger.info(
'[执行任务失败] %s, 时间: %s, 错误信息: %j', '[执行任务失败] 命令: %s, 错误信息: %j',
command, command,
new Date().toLocaleString(),
data.toString(), data.toString(),
); );
await callbacks.onError?.(data.toString()); await callbacks.onError?.(data.toString());
@ -76,9 +75,8 @@ export default class ScheduleService {
cp.on('error', async (err) => { cp.on('error', async (err) => {
this.logger.error( this.logger.error(
'[创建任务失败] %s, 时间: %s, 错误信息: %j', '[创建任务失败] 命令: %s, 错误信息: %j',
command, command,
new Date().toLocaleString(),
err, err,
); );
await callbacks.onError?.(JSON.stringify(err)); await callbacks.onError?.(JSON.stringify(err));
@ -101,9 +99,8 @@ export default class ScheduleService {
}); });
} catch (error) { } catch (error) {
await this.logger.error( await this.logger.error(
'[执行任务失败] 命令: %s, 时间: %s, 错误信息: %j', '[执行任务失败] 命令: %s, 错误信息: %j',
command, command,
new Date().toLocaleString(),
error, error,
); );
await callbacks.onError?.(JSON.stringify(error)); await callbacks.onError?.(JSON.stringify(error));
@ -167,9 +164,8 @@ export default class ScheduleService {
}, },
(err) => { (err) => {
this.logger.error( this.logger.error(
'[执行任务失败] 命令: %s, 时间: %s, 错误信息: %j', '[执行任务失败] 命令: %s, 错误信息: %j',
command, command,
new Date().toLocaleString(),
err, err,
); );
}, },

View File

@ -37,9 +37,7 @@ class TaskLimit {
public runWithCpuLimit<T>(fn: () => Promise<T>): Promise<T> { public runWithCpuLimit<T>(fn: () => Promise<T>): Promise<T> {
Logger.info( Logger.info(
`[schedule][任务加入队列] 时间: ${dayjs().format( `[schedule][任务加入队列] 运行中任务数: ${this.cpuLimitActiveCount}, 等待中任务数: ${this.cpuLimitPendingCount}`,
'YYYY-MM-DD HH:mm:ss',
)}, 运行中任务数: ${this.cpuLimitActiveCount}, 等待中任务数: ${this.cpuLimitPendingCount}`,
); );
return this.cpuLimit(fn); return this.cpuLimit(fn);
} }

View File

@ -11,17 +11,15 @@ export function runCron(cmd: string): Promise<number> {
cp.stderr.on('data', (data) => { cp.stderr.on('data', (data) => {
Logger.info( Logger.info(
'[schedule][执行任务失败] %s, 时间: %s, 错误信息: %j', '[schedule][执行任务失败] 命令: %s, 错误信息: %j',
cmd, cmd,
new Date().toLocaleString(),
data.toString(), data.toString(),
); );
}); });
cp.on('error', (err) => { cp.on('error', (err) => {
Logger.error( Logger.error(
'[schedule][创建任务失败] %s, 时间: %s, 错误信息: %j', '[schedule][创建任务失败] 命令: %s, 错误信息: %j',
cmd, cmd,
new Date().toLocaleString(),
err, err,
); );
}); });

View File

@ -252,9 +252,6 @@ const Setting = () => {
}) })
.then(async (res) => { .then(async (res) => {
setSystemLogData(await res.text()); setSystemLogData(await res.text());
setTimeout(() => {
getSystemLog();
}, 5000);
}) })
.catch((error: any) => { .catch((error: any) => {
console.log(error); console.log(error);