-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first working version with winston 3.x
- Loading branch information
Showing
11 changed files
with
2,323 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-disable require-jsdoc */ | ||
const Transport = require('winston-transport'); | ||
const Manager = require('./manager'); | ||
|
||
// | ||
// Inherit from `winston-transport` so you can take advantage | ||
// of the base functionality and `.exceptions.handle()`. | ||
// | ||
module.exports = class LogstashTransport extends Transport { | ||
constructor(options) { | ||
super(options); | ||
|
||
this.name = 'logstash'; | ||
|
||
this.manager = new Manager(options, this.onError.bind(this)); | ||
this.manager.start(); | ||
} | ||
|
||
onError(error) { | ||
this.silent = true; | ||
this.emit('error', error); | ||
} | ||
|
||
log(info, callback) { | ||
setImmediate(() => { | ||
this.emit('logged', info); | ||
}); | ||
|
||
// Perform the writing to the remote service | ||
|
||
this.manager.log(JSON.stringify(info), () => { | ||
callback(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.