mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 06:27:38 +00:00
feat: add meta to logger (#437)
This commit is contained in:
+1
-1
@@ -52,7 +52,7 @@ async function main() {
|
||||
|
||||
const promises = [];
|
||||
for (const store of Stores) {
|
||||
logger.debug(store.links);
|
||||
logger.debug('store links', {meta: {links: store.links}});
|
||||
if (store.setupAction !== undefined) {
|
||||
store.setupAction(browser);
|
||||
}
|
||||
|
||||
+11
-7
@@ -1,24 +1,28 @@
|
||||
import {Link, Store} from './store/model';
|
||||
import winston, {format} from 'winston';
|
||||
import chalk from 'chalk';
|
||||
import {config} from './config';
|
||||
import winston from 'winston';
|
||||
|
||||
const prettyJson = format.printf(info => {
|
||||
const prettyJson = winston.format.printf(info => {
|
||||
const timestamp = new Date().toLocaleTimeString();
|
||||
|
||||
if (typeof info.message === 'object') {
|
||||
info.message = JSON.stringify(info.message, null, 4);
|
||||
}
|
||||
|
||||
if (info.meta) {
|
||||
return chalk.grey(`[${timestamp}]`) + ` ${info.level} ` + chalk.grey('::') + ` ${info.message} ${chalk.magenta(JSON.stringify(info.meta, null, 2))}`;
|
||||
}
|
||||
|
||||
return chalk.grey(`[${timestamp}]`) + ` ${info.level} ` + chalk.grey('::') + ` ${info.message}`;
|
||||
});
|
||||
|
||||
export const logger = winston.createLogger({
|
||||
format: format.combine(
|
||||
format.colorize(),
|
||||
format.prettyPrint(),
|
||||
format.splat(),
|
||||
format.simple(),
|
||||
format: winston.format.combine(
|
||||
winston.format.colorize(),
|
||||
winston.format.prettyPrint(),
|
||||
winston.format.splat(),
|
||||
winston.format.simple(),
|
||||
prettyJson
|
||||
),
|
||||
level: config.logLevel,
|
||||
|
||||
Reference in New Issue
Block a user