Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using logstash option with the File transport #299

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ The File transport should really be the 'Stream' transport since it will accept
* __maxFiles:__ Limit the number of files created when the size of the logfile is exceeded.
* __stream:__ The WriteableStream to write output to.
* __json:__ If true, messages will be logged as JSON (default true).
* __logstash:__ If true, messages will be logged as JSON and formatted for logstash (default false).

*Metadata:* Logged via util.inspect(meta);

Expand Down
2 changes: 1 addition & 1 deletion lib/winston/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ exports.log = function (options) {
//
// json mode is intended for pretty printing multi-line json to the terminal
//
if (options.json) {
if (options.json || true === options.logstash) {
if (typeof meta !== 'object' && meta != null) {
meta = { meta: meta };
}
Expand Down
2 changes: 2 additions & 0 deletions lib/winston/transports/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var File = exports.File = function (options) {
}

this.json = options.json !== false;
this.logstash = options.logstash || false;
this.colorize = options.colorize || false;
this.maxsize = options.maxsize || null;
this.maxFiles = options.maxFiles || null;
Expand Down Expand Up @@ -122,6 +123,7 @@ File.prototype.log = function (level, msg, meta, callback) {
message: msg,
meta: meta,
json: this.json,
logstash: this.logstash,
colorize: this.colorize,
prettyPrint: this.prettyPrint,
timestamp: this.timestamp,
Expand Down