Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created July 14, 2020 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/14686ff164b30c5f92fe52fdca5346eb to your computer and use it in GitHub Desktop.
Save velotiotech/14686ff164b30c5f92fe52fdca5346eb to your computer and use it in GitHub Desktop.
import { createLogger, format, transports } from 'winston';
// Import Functions
const { File, Console } = transports;
// Init Logger
const logger = createLogger({
level: 'info',
});
const errorStackFormat = format((info) => {
if (info.stack) {
// tslint:disable-next-line:no-console
console.log(info.stack);
return false;
}
return info;
});
const consoleTransport = new Console({
format: format.combine(
format.colorize(),
format.simple(),
errorStackFormat(),
),
});
logger.add(consoleTransport);
}
export default logger;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment