UNPKG

kibana-123

Version:

Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic

42 lines (32 loc) 995 B
import _ from 'lodash'; import { Squeeze } from 'good-squeeze'; import { createWriteStream as writeStr } from 'fs'; import LogFormatJson from './log_format_json'; import LogFormatString from './log_format_string'; import { LogInterceptor } from './log_interceptor'; module.exports = class KbnLogger { constructor(events, config) { this.squeeze = new Squeeze(events); this.format = config.json ? new LogFormatJson(config) : new LogFormatString(config); this.logInterceptor = new LogInterceptor(); if (config.dest === 'stdout') { this.dest = process.stdout; } else { this.dest = writeStr(config.dest, { flags: 'a', encoding: 'utf8' }); } } init(readstream, emitter, callback) { this.output = readstream .pipe(this.logInterceptor) .pipe(this.squeeze) .pipe(this.format); this.output.pipe(this.dest); emitter.on('stop', () => { this.output.unpipe(this.dest); }); callback(); } };