OpenAds Logger is a Log utility for OpenAds.
OpenAds Logger is available as the @schibstedspain/openads-logger
package on npm
To install the stable version:
npm install --save @schibstedspain/openads-logger
Use the DEBUG property to know when OpenAds will run under DEBUG context (DEBUG will be true). This may be used when developing a new Connector that supports enabling a log system (p.ex. AppNexus AST).
import {DEBUG} from '@schibstedspain/openads-logger'
// example to initialize different containers when using dependency injection
const container = DEBUG ? new DebugContainer() : new DefaultContainer()
Use this function to proxy an instance so any access to its attributes or functions will be logged with a log debug call. It may be used (p.ex.) to proxy any instance created in a dependency container under DEBUG mode.
import {DEBUG, debugInstance} from '@schibstedspain/openads-logger'
// example to initialize instances that log automatically under DEBUG context in a connector's dependency container
const _getInstance = key => DEBUG ? debugInstance(getOrCreateInstance(key)) : getOrCreateInstance(key)
const someRepository = _getInstance('SomeRepository')
Use it if you need to log manually some stuff instead
import {LOG} from '@schibstedspain/openads-logger'
LOG.debug('I need to log a line manually')
OpenAds-logger is MIT licensed.