Skip to content

Commit

Permalink
fix logger and jobloader
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio1988 committed Nov 19, 2023
1 parent 3b85037 commit 46eea1b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
9 changes: 8 additions & 1 deletion packages/server/src/jobLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,15 @@ export class JobLoader {
chokidar
.watch('./jobs', {
awaitWriteFinish: true,
ignoreInitial: true,
})
.on('all', () => {
.on('change', () => {
this.load();
})
.on('add', () => {
this.load();
})
.on('unlink', () => {
this.load();
});
}
Expand Down
36 changes: 18 additions & 18 deletions packages/server/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ const logFormat = winston.format.printf(({ level, timestamp, message, label }) =
return `[${timestamp}] [${level.toUpperCase()}] [${label}] ${message}`;
});

const transport = new DailyRotateFile({
dirname: 'logs',
filename: 'rotom.log',
zippedArchive: true,
maxSize: config.logging.maxSize + 'm', // rotate when file size exceeds x MB
maxFiles: config.logging.maxAge + 'd', // keep logs for 14 days
format: winston.format.combine(
winston.format.timestamp(),
winston.format.label({ label: 'rotom' }), // Set your logger name
logFormat,
),
});
const transports = [];

// Main log file transport
if (config.logging.save) {
const mainTransport = new DailyRotateFile({
dirname: 'logs',
filename: 'rotom.log',
zippedArchive: true,
maxSize: config.logging.maxSize + 'm', // rotate when file size exceeds x MB
maxFiles: config.logging.maxAge + 'd', // keep logs for 14 days
format: winston.format.combine(winston.format.timestamp(), winston.format.label({ label: 'rotom' }), logFormat),
});
transports.push(mainTransport);
}

transports.push(new winston.transports.Console());

export const log = winston.createLogger({
level: config.logging && config.logging.debug ? 'debug' : 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.label({ label: 'rotom' }), // Set your logger name
logFormat,
),
transports: [transport],
format: winston.format.combine(winston.format.timestamp(), winston.format.label({ label: 'rotom' }), logFormat),
transports: transports,
});

0 comments on commit 46eea1b

Please sign in to comment.