mirror of
https://github.com/misskey-dev/SyslogPro.git
synced 2025-04-29 02:37:18 +09:00
fix the precision of milliseconds
This commit is contained in:
parent
597a7d0f4c
commit
263f499e09
8
index.ts
8
index.ts
@ -1248,11 +1248,11 @@ export class RFC5424 extends RFC {
|
|||||||
if (this.timestampTZ) {
|
if (this.timestampTZ) {
|
||||||
timestamp = moment(options.timestamp)
|
timestamp = moment(options.timestamp)
|
||||||
.utc()
|
.utc()
|
||||||
.format('YYYY-MM-DDThh:mm:ss.SSSSSSZ');
|
.format('YYYY-MM-DDThh:mm:ss.SSSZ');
|
||||||
} else {
|
} else {
|
||||||
timestamp = moment(options.timestamp)
|
timestamp = moment(options.timestamp)
|
||||||
.utc()
|
.utc()
|
||||||
.format('YYYY-MM-DDThh:mm:ss.SSSSSS');
|
.format('YYYY-MM-DDThh:mm:ss.SSS');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.timestampTZ) {
|
if (this.timestampTZ) {
|
||||||
@ -1272,7 +1272,7 @@ export class RFC5424 extends RFC {
|
|||||||
timeQuality += ' isSynced=1';
|
timeQuality += ' isSynced=1';
|
||||||
timeQuality += ' syncAccuracy=0';
|
timeQuality += ' syncAccuracy=0';
|
||||||
timestamp = moment(options.timestamp)
|
timestamp = moment(options.timestamp)
|
||||||
.format('YYYY-MM-DDThh:mm:ss.SSSSSSZ');
|
.format('YYYY-MM-DDThh:mm:ss.SSSZ');
|
||||||
} else {
|
} else {
|
||||||
timestamp = moment(options.timestamp)
|
timestamp = moment(options.timestamp)
|
||||||
.format('YYYY-MM-DDThh:mm:ssZ');
|
.format('YYYY-MM-DDThh:mm:ssZ');
|
||||||
@ -1283,7 +1283,7 @@ export class RFC5424 extends RFC {
|
|||||||
timeQuality += ' isSynced=1';
|
timeQuality += ' isSynced=1';
|
||||||
timeQuality += ' syncAccuracy=0';
|
timeQuality += ' syncAccuracy=0';
|
||||||
timestamp = moment(options.timestamp)
|
timestamp = moment(options.timestamp)
|
||||||
.format('YYYY-MM-DDThh:mm:ss.SSSSSS');
|
.format('YYYY-MM-DDThh:mm:ss.SSS');
|
||||||
} else {
|
} else {
|
||||||
timestamp = moment(options.timestamp).format('YYYY-MM-DDThh:mm:ss');
|
timestamp = moment(options.timestamp).format('YYYY-MM-DDThh:mm:ss');
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ describe('RFC5424 Class Tests', () => {
|
|||||||
'[ourSDID@32473 test=test]'
|
'[ourSDID@32473 test=test]'
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
resultMsg = /<190>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{6} /;
|
resultMsg = /<190>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{1,3} /;
|
||||||
expect(result).toMatch(resultMsg);
|
expect(result).toMatch(resultMsg);
|
||||||
rfc5424 = new SyslogPro.RFC5424({
|
rfc5424 = new SyslogPro.RFC5424({
|
||||||
timestamp: true,
|
timestamp: true,
|
||||||
@ -352,7 +352,7 @@ describe('RFC5424 Class Tests', () => {
|
|||||||
timestampMS: true,
|
timestampMS: true,
|
||||||
});
|
});
|
||||||
result = rfc5424.buildMessage('hello');
|
result = rfc5424.buildMessage('hello');
|
||||||
resultMsg = /<190>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{6}\+/;
|
resultMsg = /<190>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{1,3}\+/;
|
||||||
expect(result).toMatch(resultMsg);
|
expect(result).toMatch(resultMsg);
|
||||||
rfc5424 = new SyslogPro.RFC5424({
|
rfc5424 = new SyslogPro.RFC5424({
|
||||||
timestamp: true,
|
timestamp: true,
|
||||||
@ -379,7 +379,7 @@ describe('RFC5424 Class Tests', () => {
|
|||||||
timestampMS: true,
|
timestampMS: true,
|
||||||
});
|
});
|
||||||
result = rfc5424.buildMessage('hello');
|
result = rfc5424.buildMessage('hello');
|
||||||
resultMsg = /<190>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{6} /;
|
resultMsg = /<190>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{1,3} /;
|
||||||
expect(result).toMatch(resultMsg);
|
expect(result).toMatch(resultMsg);
|
||||||
rfc5424 = new SyslogPro.RFC5424({
|
rfc5424 = new SyslogPro.RFC5424({
|
||||||
timestamp: true,
|
timestamp: true,
|
||||||
@ -388,7 +388,7 @@ describe('RFC5424 Class Tests', () => {
|
|||||||
timestampMS: true,
|
timestampMS: true,
|
||||||
});
|
});
|
||||||
result = rfc5424.buildMessage('hello');
|
result = rfc5424.buildMessage('hello');
|
||||||
resultMsg = /<190>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{6}\+/;
|
resultMsg = /<190>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{1,3}\+/;
|
||||||
expect(result).toMatch(resultMsg);
|
expect(result).toMatch(resultMsg);
|
||||||
rfc5424 = new SyslogPro.RFC5424({
|
rfc5424 = new SyslogPro.RFC5424({
|
||||||
timestamp: true,
|
timestamp: true,
|
||||||
@ -409,7 +409,7 @@ describe('RFC5424 Class Tests', () => {
|
|||||||
});
|
});
|
||||||
const timestamp = new Date('2020-01-01T01:23:45.678Z');
|
const timestamp = new Date('2020-01-01T01:23:45.678Z');
|
||||||
const result = rfc5424.buildMessage('hello', { timestamp });
|
const result = rfc5424.buildMessage('hello', { timestamp });
|
||||||
expect(result.startsWith('<190>1 2020-01-01T01:23:45.678000+00:00 ')).toBe(true);
|
expect(result.startsWith('<190>1 2020-01-01T01:23:45.678+00:00 ')).toBe(true);
|
||||||
});
|
});
|
||||||
test('RFC5424 BuildMessage with hostname and applicationName options', () => {
|
test('RFC5424 BuildMessage with hostname and applicationName options', () => {
|
||||||
const rfc5424 = new SyslogPro.RFC5424();
|
const rfc5424 = new SyslogPro.RFC5424();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user