123456789101112131415161718192021222324252627282930 |
- /*
- The MIT License (MIT)
- Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contributors. (https://github.com/NikolaySuslov/lcs-reflector/blob/master/LICENSE.md)
- */
- var winston = require('winston');
- const logger = winston.createLogger({
- level: 'info',
- format: winston.format.json(),
- transports: [
- //
- // - Write to all logs with level `info` and below to `combined.log`
- // - Write all logs error (and below) to `error.log`.
- //
- new winston.transports.File({ filename: 'error.log', level: 'error' }),
- //new winston.transports.File({ filename: 'combined.log' })
- ]
- });
-
- //
- // If we're not in production then log to the `console` with the format:
- // `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
- //
- if (process.env.NODE_ENV !== 'production') {
- logger.add(new winston.transports.Console({
- format: winston.format.simple()
- }));
- }
- module.exports = logger;
|