Skip to content

Commit

Permalink
Merge branch 'master' into freeze-const
Browse files Browse the repository at this point in the history
  • Loading branch information
72636c authored Oct 9, 2023
2 parents 6d82452 + 8e647f1 commit e5d0a75
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .changeset/moody-bobcats-travel.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Omit request headers
- `x-envoy-peer-metadata-id`
- `x-envoy-upstream-service-time`

If you would like to opt out of this behaviours, you can provide an empty list or your own list of request headers to `omitHeaderNames`:
To opt out of this behaviour, provide an empty list or your own list of omissible request headers to `omitHeaderNames`:

```diff
const logger = createLogger({
Expand Down
38 changes: 33 additions & 5 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ function testLog(
logger[method ?? 'info'](input);

const log: any = await once(stream, 'data');
expect(log).toMatchObject(output);
expect(log).toStrictEqual({
level: 30,
name: 'my-app',
timestamp: expect.any(String),
...output,
});
expect(inputString).toEqual(JSON.stringify(input));
expect(log).toHaveProperty('timestamp');
});
}

Expand Down Expand Up @@ -194,6 +198,7 @@ testLog(
err: {
message: 'a'.repeat(64).split(''),
},
msg: new Array(64).fill('a'),
},
);

Expand Down Expand Up @@ -228,9 +233,22 @@ testLog(
foo: new Error('Oh my, this is an error too!'),
},
{
error: { message: 'Ooh oh! Something went wrong' },
err: { message: 'Woot! Another one!' },
foo: { message: 'Oh my, this is an error too!' },
error: {
message: 'Ooh oh! Something went wrong',
name: 'Error',
stack: expect.stringMatching(/^Error: Ooh oh! Something went wrong\n/),
},
err: {
message: 'Woot! Another one!',
stack: expect.stringMatching(/^Error: Woot! Another one!\n/),
type: 'Error',
},
foo: {
message: 'Oh my, this is an error too!',
name: 'Error',
stack: expect.stringMatching(/^Error: Oh my, this is an error too!\n/),
},
msg: 'Woot! Another one!',
},
);

Expand Down Expand Up @@ -315,12 +333,15 @@ testLog(
},
},
err: {
code: 'ECONNABORTED',
config: {
headers: {
Accept: 'application/json, text/plain, */*',
authorization: '[Redacted]',
},
timeout: 400,
},
message: 'timeout of 400ms exceeded',
request: {
_options: {
method: 'get',
Expand All @@ -329,8 +350,15 @@ testLog(
authorization: '[Redacted]',
},
},
domain: null,
},
stack: expect.stringMatching(/^Error: timeout of 400ms exceeded\n/),
type: 'Object',
},
level: 40,
meta: { message: 'timeout of 400ms exceeded', attempt: 0 },
msg: 'Retrying Request',
v: 1,
},
);

Expand Down

0 comments on commit e5d0a75

Please sign in to comment.