2016-08-20 05:08:46 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
2018-11-06 22:59:53 +08:00
|
|
|
import { createLogger, format, transports } from 'winston';
|
2021-09-25 03:20:37 +08:00
|
|
|
import WinstonPromTransport from './prom-metrics/winstonPromTransport';
|
2016-08-20 05:08:46 +08:00
|
|
|
|
2021-06-17 10:20:49 +08:00
|
|
|
const LOG_CONFIG = Meteor?.settings?.private?.serverLog || {};
|
2019-08-03 01:20:06 +08:00
|
|
|
const { level } = LOG_CONFIG;
|
|
|
|
|
2018-11-06 22:59:53 +08:00
|
|
|
const Logger = createLogger({
|
2019-08-03 01:20:06 +08:00
|
|
|
level,
|
2018-11-06 22:59:53 +08:00
|
|
|
format: format.combine(
|
2018-12-10 09:08:16 +08:00
|
|
|
format.colorize({ level: true }),
|
2018-11-06 22:59:53 +08:00
|
|
|
format.splat(),
|
|
|
|
format.simple(),
|
|
|
|
),
|
2019-08-03 01:20:06 +08:00
|
|
|
transports: [
|
|
|
|
// console logging
|
|
|
|
new transports.Console({
|
|
|
|
prettyPrint: false,
|
|
|
|
humanReadableUnhandledException: true,
|
|
|
|
colorize: true,
|
|
|
|
handleExceptions: true,
|
|
|
|
level,
|
|
|
|
}),
|
2021-09-25 03:20:37 +08:00
|
|
|
// export error logs to prometheus
|
|
|
|
new WinstonPromTransport({
|
|
|
|
level: 'error',
|
|
|
|
}),
|
2019-08-03 01:20:06 +08:00
|
|
|
],
|
2016-05-05 01:00:57 +08:00
|
|
|
});
|
2016-08-20 05:08:46 +08:00
|
|
|
|
|
|
|
export default Logger;
|
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
export const logger = Logger;
|