-
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.
Feature/34 logger improvements (#38)
* Set more sensible defaults for logger in driver/client and pool. * add logger types to index.ts exports * fix issue where LogLevel.Off would not correctly be set in the constructor, fixed by using a default in the constructor instead and not doing an 'implicit' check for undefined + gave explicit values to all LogLevel levels. * Add tests for logger * Changes doc
- Loading branch information
1 parent
d1aa19e
commit 6ae29e7
Showing
6 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
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
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,44 @@ | ||
import { LogLevel, Logger } from './logger'; | ||
|
||
describe('Logger', () => { | ||
it('Should "console.log()" with default Log level (= debug) when using logger.debug()', () => { | ||
const defaultLogger = new Logger(); | ||
|
||
const logSpy = jest.spyOn(global.console, 'log'); | ||
defaultLogger.debug('hello'); | ||
expect(logSpy).toHaveBeenCalled(); | ||
}); | ||
it('Should "console.log()" with log level debug when using logger.debug()', () => { | ||
const defaultLogger = new Logger(LogLevel.Debug); | ||
|
||
const logSpy = jest.spyOn(global.console, 'log'); | ||
defaultLogger.debug('hello'); | ||
expect(logSpy).toHaveBeenCalled(); | ||
}); | ||
it('Should not "console.log" with log level "off" when using logger.debug()', () => { | ||
const defaultLogger = new Logger(LogLevel.Off); | ||
|
||
const logSpy = jest.spyOn(global.console, 'log'); | ||
defaultLogger.debug('hello'); | ||
expect(logSpy).not.toHaveBeenCalled(); | ||
}); | ||
it('Should not "console.log" with a lower debug level than debug when using logger.debug()', () => { | ||
const defaultLogger = new Logger(LogLevel.Error); | ||
|
||
const logSpy = jest.spyOn(global.console, 'log'); | ||
defaultLogger.debug('hello'); | ||
expect(logSpy).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('Should "console.log" with a higher debug level than debug when using logger.debug()', () => { | ||
const defaultLogger = new Logger(LogLevel.Trace); | ||
|
||
const logSpy = jest.spyOn(global.console, 'log'); | ||
defaultLogger.debug('hello'); | ||
expect(logSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
}); |
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
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