Skip to content

Commit

Permalink
fix: Fix timestamp formatting
Browse files Browse the repository at this point in the history
- Use the correct time zone (fixes winstonjs#138)
- Fix formatting for milliseconds (fixes winstonjs#156)
- Add tests
  • Loading branch information
bmaupin committed Sep 30, 2021
1 parent 4b74b36 commit a4926ad
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/winston-syslog.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const dgram = require('dgram');
const net = require('net');
const secNet = require('tls');
const utils = require('./utils');
const glossy = require('glossy');
const glossy = require('@myndzi/glossy');
const winston = require('winston');
const Transport = require('winston-transport');
const { MESSAGE, LEVEL } = require('triple-beam');
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"syslog"
],
"dependencies": {
"glossy": "^0.1.7"
"@myndzi/glossy": "^0.1.11"
},
"optionalDependencies": {
"unix-dgram": "2.0.3"
Expand Down
12 changes: 10 additions & 2 deletions test/format-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const vows = require('vows');
const assert = require('assert');
const Syslog = require('../lib/winston-syslog.js').Syslog;
const dgram = require('dgram');
const parser = require('glossy').Parse;
const parser = require('@myndzi/glossy').Parse;

const PORT = 11229;
let server;
Expand Down Expand Up @@ -69,7 +69,7 @@ vows
assert.notEqual(msg.host, 'localhost');
transport.close();
},
'setting appName option to hello': {
'setting appName option to hello and type to 5424': {
'topic': function () {
const self = this;
server.once('message', function (msg) {
Expand All @@ -93,6 +93,14 @@ vows
},
'should have appName field set to hello': function (msg) {
assert.equal(msg.appName, 'hello');
},
'should have proper time zone': function (msg) {
const now = new Date();
assert.equal((Math.abs((now - msg.time) / 1000) < 300), true);
},
'should have proper milliseconds format': function (msg) {
const milliseconds = msg.originalMessage.split(' ')[1].slice(20, 23);
assert.equal(isNaN(milliseconds), false);
transport.close();
},
'setting app_name option to hello': {
Expand Down
2 changes: 1 addition & 1 deletion test/unix-connect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const vows = require('vows');
const assert = require('assert');
const unix = require('unix-dgram');
const parser = require('glossy').Parse;
const parser = require('@myndzi/glossy').Parse;
const Syslog = require('../lib/winston-syslog').Syslog;

const { MESSAGE, LEVEL } = require('triple-beam');
Expand Down

0 comments on commit a4926ad

Please sign in to comment.