Skip to content

Commit

Permalink
feat(logger): logger will not print function names when objects have …
Browse files Browse the repository at this point in the history
…funcs
  • Loading branch information
jmcdo29 committed Sep 12, 2020
1 parent 26dcd25 commit c496d16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 2 additions & 1 deletion packages/logger/src/logger/ogma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export class Ogma {
return this.wrapInBrackets(value.toString());
}
if (typeof value === 'function') {
return this.wrapInBrackets('Function');
console.log(value);
return this.wrapInBrackets(`Function: ${value.name || '(anonymous)'}`);
}
if (typeof value === 'object' && value !== null) {
if (seen.has(value)) {
Expand Down
13 changes: 4 additions & 9 deletions packages/logger/test/ogma.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,10 @@ describe('Ogma Class', () => {
ogma = new Ogma({ stream: mockStream });
ogma.log(circularObject);
expect(mockStream.write).toBeCalledTimes(1);
expect(mockStream.write.mock.calls[0][0]).toEqual(
expect.stringContaining('[Circular]'),
);
expect(mockStream.write.mock.calls[0][0]).toEqual(
expect.stringContaining('[Function]'),
);
expect(mockStream.write.mock.calls[0][0]).toEqual(
expect.stringContaining('[Symbol(hello)]'),
);
const writeString = mockStream.write.mock.calls[0][0];
expect(writeString).toEqual(expect.stringContaining('[Circular]'));
expect(writeString).toEqual(expect.stringContaining('[Function:'));
expect(writeString).toEqual(expect.stringContaining('[Symbol(hello)]'));
});
it('should follow the context, application, and message of a json', () => {
ogma = new Ogma({
Expand Down

0 comments on commit c496d16

Please sign in to comment.