Skip to content

Commit

Permalink
logger: fix issue with local file being generated and add support for…
Browse files Browse the repository at this point in the history
… array of tags

Fixes: No Issue / Ticket
PR-URL: #7 
Reviewed-By: James Drenter <james.drenter@turner.com>
Reviewed-By: Jamie Young <james.young@turner.com>
  • Loading branch information
DrEnter authored and jamsyoung committed Jan 19, 2017
1 parent 4eb56b7 commit 5bc95bc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function logger(options) {

options = options || {};
options.console = options.console || {};
options.file = options.file || {};
options.logzio = options.logzio || {};

Logger = new winston.Logger({
Expand All @@ -48,7 +49,6 @@ function logger(options) {
important: 'green'
},
transports: [
new (winston.transports.File)({filename: 'logs.log'}),
new winston.transports.Console({
colorize: options.console.colorize || true,
formatter: options.console.formatter || undefined,
Expand All @@ -65,13 +65,17 @@ function logger(options) {
]
});

if (typeof options.logzio.tag !== 'undefined') {
if (typeof options.file.filename === 'string' && options.file.filename.length !== 0) {
Logger.add(new (winston.transports.File)(options.file));
}

if (typeof options.logzio.tag !== 'undefined' || Array.isArray(options.logzio.tags)) {
Logger.add(logzioWinstonTransport,
{
bufferSize: options.logzio.bufferSize || 1,
debug: options.logzio.debug || false,
extraFields: {
tags: [options.logzio.tag]
tags: options.logzio.tag ? [options.logzio.tag] : options.logzio.tags
},
level: process.env.LOGZIO_LOG_LEVEL || 'important',
sendIntervalMs: options.logzio.sendIntervalMS || 1000 * 2,
Expand Down

0 comments on commit 5bc95bc

Please sign in to comment.