-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[server:logger] Create a module `server/logger.ts` to provide a singular pino logger instance [server:httpLogger] Create a module `server/httpLogger.ts` to provide a singular pino-http logger instance
- Loading branch information
1 parent
7c1b53f
commit effc896
Showing
8 changed files
with
66 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable global-require */ | ||
import pinoHttp from 'pino-http'; | ||
|
||
jest.mock('pino-http'); | ||
|
||
const mockLogger = jest.fn(); | ||
|
||
let httpLogger; | ||
|
||
describe('httpLogger', () => { | ||
beforeAll(() => { | ||
pinoHttp.mockReturnValue(mockLogger); | ||
httpLogger = require('../httpLogger').default; | ||
}); | ||
|
||
test('returns an instance of a pino httpLogger', () => { | ||
expect(httpLogger).toEqual(mockLogger); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable global-require */ | ||
import pino from 'pino'; | ||
|
||
jest.mock('pino'); | ||
|
||
const mockLogger = jest.fn(); | ||
|
||
let logger; | ||
|
||
describe('logger', () => { | ||
beforeAll(() => { | ||
pino.mockReturnValue(mockLogger); | ||
logger = require('../logger').default; | ||
}); | ||
|
||
test('returns an instance of a pino logger', () => { | ||
expect(logger).toEqual(mockLogger); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import pinoHttp from 'pino-http'; | ||
|
||
export const httpLogger = pinoHttp(); | ||
|
||
export default httpLogger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import pino from 'pino'; | ||
|
||
const logger = pino(); | ||
|
||
export default logger; |