Version 2 format file text
simon-p-r opened this issue · comments
Is there anyway to format text that is written to file, maybe pass some options to print all on same line? Please see this example
var opts = {
console: {
},
file: {
filename: './logs/test.log'
}
};
var logger = require('bucker').createLogger(opts);
logger.info('Hello world', 1234, opts, logger);
Would print this to file
2015-03-12T12:07:32 info: Hello world 1234 { console: { level: 0 },
file: { filename: './logs/test.log', level: 0 } } { events:
{ domain: null,
_events:
{ debug: [Object],
info: [Object],
warn: [Object],
error: [Object],
exception: [Object],
access: [Object],
stat: [Object] },
_maxListeners: undefined },
transports:
[ { events: [Object], levels: [Object], options: [Object] },
{ events: [Object],
levels: [Object],
options: [Object],
filestream: [Object] } ],
name: '',
emailOptions: undefined,
_tags: [] }
I appreciate this object is verbose but maybe limiting the depth of object would be one way of restricting any overkill. I have tried adding some lines in file module to print on one line however I can't seem to trim the whitespace left on line, adding these lines
line = line.replace(/\r?\n|\r/g);
line = line.replace(/undefined/g, '');
Printed this
2015-03-12T12:16:25 info: Hello world 1234 { console: { level: 0 }, file: { filename: './logs/test.log', level: 0 } } { events: { domain: null, _events: { debug: [Object], info: [Object], warn: [Object], error: [Object], exception: [Object], access: [Object], stat: [Object] }, _maxListeners: }, transports: [ { events: [Object], levels: [Object], options: [Object] }, { events: [Object], levels: [Object], options: [Object], filestream: [Object] } ], name: '', emailOptions: , _tags: [] }
hmm, this is a tricky one. currently file output is just whatever the user passes run through util.format
from node's core util library. we would likely have to implement our own format utility to allow passing in options to do this properly. i'll look into it.
Thanks for the heads up