forked from foolip/mdn-bcd-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.js
32 lines (27 loc) · 741 Bytes
/
logger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// mdn-bcd-collector: logger.js
// Logging output module to log to either the console or GAE cloud
//
// © Google LLC, Gooborg Studios
// See the LICENSE file for copyright details
//
import winston from 'winston';
import {LoggingWinston} from '@google-cloud/logging-winston';
const getTransport = () => {
/* c8 ignore next 3 */
if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
return new LoggingWinston();
}
return new winston.transports.Console({
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple()
)
});
};
const logger = winston.createLogger({
level: 'info',
transports: [getTransport()],
silent: process.env.NODE_ENV === 'test'
});
export default logger;