Skip to content

Commit

Permalink
Use Winston for logging whenever possible and always log to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2b3bfa0 authored Sep 23, 2021
1 parent 46cd351 commit 0481165
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions bin/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const configureLogger = (level) => {
),
transports: [
new winston.transports.Console({
stderrLevels: Object.keys(winston.config.npm.levels),
handleExceptions: true,
handleRejections: true,
level
Expand Down
17 changes: 8 additions & 9 deletions bin/cml/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,13 @@ const shutdown = async (opts) => {
}
};

if (error) winston.error(error);
console.log(
JSON.stringify({
level: error ? 'error' : 'info',
status: 'terminated',
reason
})
);
if (error) {
winston.error(error, { reason, status: 'terminated' });
} else {
winston.info('runner status', { reason, status: 'terminated' });
}

winston.info(`waiting ${RUNNER_DESTROY_DELAY} before exiting...`);
await sleep(RUNNER_DESTROY_DELAY);

if (cloud) {
Expand Down Expand Up @@ -229,7 +228,7 @@ const runLocal = async (opts) => {

const dataHandler = async (data) => {
const log = await cml.parseRunnerLog({ data });
log && winston.info('runner log', log);
log && winston.info('runner status', log);

if (log && log.status === 'job_started') {
RUNNER_JOBS_RUNNING.push({ id: log.job, date: log.date });
Expand Down

0 comments on commit 0481165

Please sign in to comment.