Skip to content

Commit c751beb

Browse files
committed
fix: correctly log sequence
1 parent 04f014a commit c751beb

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/Roarr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const stringify = fastJson({
2929
type: 'string',
3030
},
3131
sequence: {
32-
type: 'integer',
32+
type: 'string',
3333
},
3434
time: {
3535
type: 'integer',

test/roarr/integrations/log.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ test.beforeEach(async (t) => {
2121
ROARR,
2222
} = await import('../../../src/Roarr');
2323

24+
sinon.restore();
25+
2426
const write = sinon.stub(ROARR, 'write');
2527

2628
// eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -44,5 +46,25 @@ test('ROARR.write overrides message handler', (t) => {
4446
t.is(write.callCount, 1);
4547
t.is(write.firstCall.args.length, 1);
4648

47-
t.regex(write.firstCall.args[0], /{"context":{"logLevel":30},"message":"foo","sequence":0,"time":\d+,"version":"\d\.\d\.\d"}/);
49+
t.regex(write.firstCall.args[0], /{"context":{"logLevel":30},"message":"foo","sequence":"0","time":\d+,"version":"\d\.\d\.\d"}/);
50+
});
51+
52+
test('produces sequence', (t) => {
53+
const {
54+
Roarr,
55+
write,
56+
} = t.context;
57+
58+
const log = Roarr;
59+
60+
log.adopt(() => {
61+
log.adopt(() => {
62+
log.info('foo');
63+
});
64+
});
65+
66+
t.is(write.callCount, 1);
67+
t.is(write.firstCall.args.length, 1);
68+
69+
t.regex(write.firstCall.args[0], /{"context":{"logLevel":30},"message":"foo","sequence":"1.0.0","time":\d+,"version":"\d\.\d\.\d"}/);
4870
});

0 commit comments

Comments
 (0)