Skip to content

Commit

Permalink
feat(logging): add timestamp (#48)
Browse files Browse the repository at this point in the history
Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
  • Loading branch information
wuruochong and jef committed Sep 19, 2020
1 parent d907092 commit 6c3cd01
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import winston, {format} from 'winston';

const prettyJson = format.printf(info => {
const timestamp = new Date().toLocaleTimeString();

if (typeof info.message === 'object') {
info.message = JSON.stringify(info.message, null, 4);
}

return `${info.level} :: ${info.message}`;
return `[${timestamp}] ${info.level} :: ${info.message}`;
});

export const Logger = winston.createLogger({
Expand Down

0 comments on commit 6c3cd01

Please sign in to comment.