Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
/ OpenAds-logger Public archive

Logger utility and debug enabler for OpenAds and its connectors

License

Notifications You must be signed in to change notification settings

scm-spain/OpenAds-logger

Repository files navigation

OpenAds Logger

Build status codecov

OpenAds Logger is a Log utility for OpenAds.

Installation

OpenAds Logger is available as the @schibstedspain/openads-logger package on npm To install the stable version:

npm install --save @schibstedspain/openads-logger

Usage

The DEBUG property:

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()

The debugInstance function:

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')

The LOG singleton:

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')

License

OpenAds-logger is MIT licensed.

About

Logger utility and debug enabler for OpenAds and its connectors

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published