Created
February 19, 2019 17:40
-
-
Save jordangarcia/9cee327b94ea451026bd956619f4e0dc to your computer and use it in GitHub Desktop.
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
const core = require('@optimizely/js-sdk-core') | |
// this will prefix all log messages with 'myModuleName: ' | |
const logger = createLogger('myModuleName') | |
logger.log(core.LogLevel.INFO, 'same .log() API as before') | |
// or you can use debug / info / warn / error | |
logger.debug('this is a debug message') | |
logger.info('this is an info message') | |
logger.warn('this is a warning') | |
logger.error('this is an error') | |
// you can also pass arguments to string interpolate | |
// the benefit of doing it this way is it wont be evaluated | |
// unless the log level should log | |
logger.info('user got variation "%s" for experiment "%s"', variationKey, experimentKey) | |
logger.error('error occurred: "%s"', ex.message) | |
// if the last argument passed is an error object, it will call errorHandler.handlerError | |
logger.warn("i got an error", ex) | |
// if only an error is passed it will log ex.message and call errorHandler.handlerError | |
logger.error(ex) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment