JavaScript port of Android's timber library.
Behavior is added through Tree instances. You can install an instance by calling Timber.plant. Installation of Trees should be done as early as possible.
Usage
Two easy steps:
- Install any Tree instances you want.
- Call Timber's static methods everywhere.
Code Demo
Basic Usage
const {Timber, DebugTree} = require('@crazyorr/timber');
Timber.plant(new DebugTree());
Timber.debug('debug');
Timber.info('info');
Timber.warn('warn');
Timber.error('error');
Timber.tag('tag-1').debug('debug');
Timber.tag('tag-2').info('info');
Timber.tag('tag-3').warn('warn');
Timber.tag('tag-4').error('error');
Customize Tree
const {Timber, Tree, Level} = require('@crazyorr/timber');
class CustomTree extends Tree {
isLoggable(level, tag) {
return level >= Level.Warn;
}
log(level, tag, message, ...optionalParams) {
switch (level) {
case Level.Debug:
break;
case Level.Info:
break;
case Level.Warn:
break;
case Level.Error:
break;
}
}
}
Timber.plant(new CustomTree());
Installation
$ npm install @crazyorr/timber
Author
License
This project is licensed under the ISC License