Skip to content

Commit

Permalink
fixed error handler to not crash server
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanrahic committed Aug 6, 2020
1 parent 31b0091 commit 9864ca8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Create your free account and access token [here](https://apps.sematext.com/ui/re
## Usage

```js
const Logsene = require('../sematext/winston-logsene/lib')
const { createLogger, format, config } = require('winston')

const { createLogger, config } = require('winston')
var Logsene = require('winston-logsene')
var logger = createLogger({
levels: config.npm.levels,
transports: [new Logsene({
Expand Down
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ var Logsene = function (options) {
const { err } = e

if (err.code === 'EAI_AGAIN') {
console.log(new Date().toISOString() + ` winston-logsene: cannot reach the receiver URL: ${err.url}, please check your network connection ...`)
console.error(new Date().toISOString() + ` winston-logsene: cannot reach the receiver URL: ${err.url}, please check your network connection ...`)
return
}

self.emit('error', e)
self.emit('warning', e)
console.error(new Date().toISOString() + ` winston-logsene: cannot reach the receiver URL: ${err.url}, please check the error message ...`, err)
})
this.logger.on('log', function (data) {
self.logCount = self.logCount - data.count
Expand Down

0 comments on commit 9864ca8

Please sign in to comment.