1 import { createReadStream } from 'fs'
2 import { join } from 'path'
3 import { createInterface } from 'readline'
4 import * as winston from 'winston'
5 import { readFileBufferPromise } from '../server/helpers/core-utils'
6 import { CONFIG } from '../server/initializers/constants'
8 const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
10 const logger = new winston.Logger({
12 new winston.transports.Console({
15 handleExceptions: true,
16 humanReadableUnhandledException: true,
32 const path = join(CONFIG.STORAGE.LOG_DIR, 'all-logs.log')
33 console.log('Opening %s.', path)
35 const rl = createInterface({
36 input: createReadStream(path)
39 rl.on('line', line => {
40 const log = JSON.parse(line)
41 const additionalInfo: any = {}
43 Object.keys(log).forEach(logKey => {
44 if (logKey !== 'message' && logKey !== 'level') additionalInfo[logKey] = log[logKey]
47 logLevels[log.level](log.message, additionalInfo)