elosnoc
v0.13.0
Published
A simple, light-weighted and highly-customizable logger system for javascript.
Downloads
335
Readme
Elosnoc
A simple, light-weighted and highly-customizable logger system for javascript.
What's new
Updated in v0.13.0
- Add new API
hookNativeConsole
- Fixes the format of combinator
fancy
- Optimize the logic of the log function: now renderer, combinator and post-hook function will only be executed when needed
Updated in v0.12.0
- Now log function supports variadic parameters
- Add the concepts of Combinator, which defines how to combine the rendered result from Renderer to support variadic-parameters log function
- Add Combinator generator
gulp
. - Update the implementation of
fancy
. Part of implementation offancy
is removed to preset combinator wrappercandy
in order to keep compatibility with variadic-parameters log function syslog
is now a combinator wrapper instead of renderer wrapper
Updated in v0.11.0
- Post-hook is always optional.
- Use bundler parameters for renderer, printer and post-hook
- Default renderer is renamed to
fancy
- Add a new renderer:
vanilla
. Just explore it:) - Add a renderer wrapper
syslog
to generate logs that fit syslog protocol
Updated in v0.10.0
- Typescript enhancement: add support for customize the the type of the arguments of
renderer
- Add support for customize the printer function
- Renderer and post-hook function now can read
logLevel
Install
npm install elosnoc
Basic Usage
import { Elosnoc } from 'elosnoc'
const elosnoc = Elosnoc()
elosnoc.info('💬YAHO!')
elosnoc.warn('⚠️DANGER!')
elosnoc.error('❌OH NO!')
elosnoc.emergency('☠️KERNEL PANIC')
API
Elosnoc
function Elosnoc<T = unknown, P = string, K = string>(ElosnocOptions?: ElosnocOptions<T, P>): Logger
Get the logger.
Options
logLevel
Set thelogLevel
, default to'DEBUG'
renderer
Customize the renderer, default tofancy
combinator
Customize the combinator, default tocandy(gulp())
printer
Customize the printer, default topandora
postHook
Customize the post-hook, default to()=>{}
(do nothing)
hookNativeConsole
function hookNativeConsole: (logger: Logger<any>) => (hooks: LogLevel2[]) => void;
Install hooks into native console
object using the log function from logger
.
Presets
Elosnoc provides some preset renderer, combinator generator and wrapper. It will by default use some of them, to provides a out-of-box experience.
fancy
Type: Renderer
Render logs with some awesome styles.
gulp
Type: Combinator generator
Join all strings rendered with the separator given
candy
Type: Combinator wrapper
Adds timestamp info to the header of the log
syslog
Type: Combinator wrapper
Adds syslog protocol code to the header of the log.
vanilla
Type: Renderer
~~A powerful renderer that can implement highly-performance JavaScript~~
LICENSE
Elosnoc is licensed under LGPL-2.1.