diff --git a/index.js b/index.js index 69a814c2dceaeec9a061aaf4872450c643f08bfa..5ca8d8b0cd65ffe4ca5f5f5e8f92582317dfca48 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,3 @@ -const udp = require('dgram') - function Log (options) { this.levels = { 'DEBUG': 5, @@ -27,7 +25,8 @@ function Log (options) { this.hostname = os.hostname() } if (this.options.graylog && this.options.graylog.active) { - this.udpclient = udp.createSocket('udp4') + this.udp = require('dgram') + this.udpclient = this.udp.createSocket('udp4') } if (this.options.file) { this.fs = require('fs') @@ -122,11 +121,11 @@ function Log (options) { } if (this.options.graylog && this.options.graylog.active) { let buffed = Buffer.from(JSON.stringify({ - short_message: message, + short_message: msg, timestamp: Date.now() / 1000, hostname: this.hostname, facility: this.name, - level:tag + level: tag })) this.udpclient.send(buffed, 0, buffed.length, this.options.graylog.port, this.options.graylog.server, (error) => { if (error) {