diff --git a/index.js b/index.js index 0e0f98d53ac03303db9f3e8cb2617546608a4730..4d6808024fd9f7de073f159b70e5dd98d6a95c58 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,4 @@ function Log (options) { - this.moment = require('moment') this.path = require('path') this.fs = require('fs') this.os = require('os') @@ -27,7 +26,7 @@ function Log (options) { this.log('DEBUG', message) } this.log = function (tag, message) { - let msg = this.moment().format('YYYY-MM-DDTHH:mm:ss') + '\t' + this.hostname + '\t' + this.name + '\t' + tag + '\t' + message + let msg = this.getDate() + '\t' + this.hostname + '\t' + this.name + '\t' + tag + '\t' + message switch (tag) { case 'INFO': console.log(msg) @@ -50,22 +49,27 @@ function Log (options) { if (this.options.graylog) { switch (tag) { case 'INFO': - this.graylogger.info(msg) + this.graylogger.info(message) break case 'WARN': - this.graylogger.warning(msg) + this.graylogger.warning(message) break case 'ERROR': - this.graylogger.error(msg) + this.graylogger.error(message) break case 'DEBUG': - this.graylogger.debug(msg) + this.graylogger.debug(message) break default: - this.graylogger.notice(msg) + this.graylogger.notice(message) } } } + this.getDate = function () { + var tzoffset = (new Date()).getTimezoneOffset() * 60000 // offset in milliseconds + var localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1) + return localISOTime.split('.')[0].trim() + } return this } module.exports = Log diff --git a/package.json b/package.json index 4737b0991c28ccd7e1b4dd21b1bda877b0f62d38..43f3dd9e1659bee3d472e5ba3bc6e2a4a4a6ca66 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "author": "Dominik Sigmund", "license": "ISC", "dependencies": { - "graylog2": "^0.2.1", - "moment": "^2.22.2" + "graylog2": "^0.2.1" } }