Static
cExpose the whole ansi-colors package as "c", per its convention. Useful to have with you for logging!
Optional
debugLevel: numberOptional
logLevel: Optional
debugLevel: numberOptional
options: OptionsAtConstructorOptional
debugLevel: numberOptional
options: OptionsAtConstructorOptional
logLevel: Optional
debugLevel: numberStatic
updateAdd a TLogPathOptions object, where:
Keys are paths in your project's filesystem (e.g. 'src/some/module'
). They can be Replaced Paths or use shortcuts (see below).
Values are either:
an object of type LogZen Options eg {colors: true}
OR a number (even parsable string number), interpreted as debugLevel
OR a logLevel
string eg 'warn'
, 'log'
etc
For example:
{
'/': {colors: false, logLevel: 'warn'} // obj as is - on root (CWD) of project, siting only before defaultOptions
'./some/path': 'info', // becomes {logLevel: 'info'}
'some/other/buggy/path': '100', // becomes {debugLevel: 100}
}
with all your paths and corresponding options for each path.
When calling multiple times, paths are updated (or added) with a custom _.merge
over existing options.
Thus, existing paths are not blindly overwritten, but their contents are merged (i.e. updated).
The key in logPathOptions object, is some path in your project relative to CWD, for example:
/
# The root of your project, i.e the CWD
src/domain/entities
# a relative path to your CWD
or
MyLib@/some/path
# refer by pathReplacement + extra path
or
node_modules/lib/dist/some/path
# useful for foreign libraries
or
[~]/some/path
which is a special shortcut for "current file I'm calling from". If [~]
is in your path string, it is replaced with the filepath of the .js
/.ts
file you're calling it from (without the .js ext, & adjusted for CWD internally). For example [~]/some/path
will be replaced with where/ever/youare/calling/from/some/path
an object with {[logPath:string]: Options}
when calling from a nested file paths, but you want to capture the real file called from, use this to adjust the stack depth. Default is 0, i.e. the file calling LogZen.updateLogPathOptions()
LogZen for fluent API
Static
addAdd a TPathReplacements object, where:
keys are paths in your project's filesystem (e.g. 'src/some/project'
)
values are replacements (eg 'MyProject'
).
For example:
{
'src/domain/entities': 'DomainEntities',
'src/domain': 'Domain',
'[~]/../..': 'Source',
}
See pathReplacements for more options & examples
LogZen for fluent API
Static
inspectStatic
clearStatic
timerStart a timer on ALL instances, and next time you print with any l.xxx() log method onany instance, it displays how long it took (in the header).
Optional
always: booleanrestart timer automatically when it elapses - see always restart timer
the timestamp when the timer was started (or null if always=false)
Static
timerStatic
timerStops the current static timer, and returns the difference since static LogZen.timer()
was started, in milliseconds (like .timerNow()
).
It restarts the timer if always
was set to true in l.timer(true)
the difference since static LogZen.timer()
was started, in milliseconds
Static
resetThe options()
method, either gets current effective options OR it updates the options of the instance (and returns it).
{colors: true, logLevel: 'warn'}
.this
, i.e the logger instance, so you can do fluently do l.options({colors: false}).log('Hello boring world')
Options current effective options
The options()
method, either gets current effective options OR it updates the options of the instance (and returns it).
newOptions
(in this variant) to update existing instance options, causing revaluation of effective options. It returns this
, i.e the logger instance, so you can do fluently do l.options({colors: false}).log('Hello boring world')
{colors: true, logLevel: 'warn'}
.LogZen instance
Start a timer on specific instance, and next time you print l.xxx()
with any log method on specific instance, it displays how long it took (in the header).
Optional
always: booleanrestart timer automatically when it elapses - see always restart timer
the timestamp when the timer was started (or null if always=false)
Protected
Static
_collectFor a given path of a runtime log(), for example ['src', 'entities', 'customer'],
it retrieves all Options from PATHS_OPTIONS_KEY
starting from deepest kid, up to the top of the hierarchy to the root
(ie ['zen', 'objects'], then ['zen'] & ['']
It reads them from LogZen._logPathOptions
that holds these static (i.e global LogZen) options.
Optional
path: string | string[]the path to collect options for. Default is empty array, which means root options
options objects in reverse collected order (root on top, last path at bottom), ready for blending (i.e Object.assign etc ;-)
Protected
_refreshProtected
_addProtected
_getProtected
_willProtected
_actualThe actual log method, that all other log methods call.
Protected
_actualProtected
_actualProtected
The actual log method for leveled log (i.e debug
& trace
), that all other log methods call.
Optional
argsToPrint: any[]Prints using console.table()
with some enhancements and caveats
Prints using console.table()
with some enhancements and caveats, returning the lastArg (which is also what is passed to console.table())
Prints using console.dir()
if console output is used, but its not part of logLevel methods
It has a fixed ELogLevel.log
severity.
Prints using console.dir()
if console output is used, but it's not part of logLevel methods
It has a fixed ELogLevel.log
severity.
Protected
Static
_instanceProtected
Static
_pathProtected
Static
_resolveProtected
Static
_blendProtected
Static
_logProtected
Static
_optionsProtected
Static
_timerProtected
Static
_timerProtected
_CWDProtected
_absoluteProtected
_relativeProtected
_optionsProtected
_resolvedProtected
_loggerProtected
_realProtected
_instanceProtected
_optionsProtected
_effectiveProtected
_kidsProtected
_kidProtected
_kidProtected
_parentProtected
_kidsProtected
_kidProtected
_kidProtected
_timerProtected
_timerProtected
_leveledProtected
_debugProtected
_trace
See
LogZen API Documentation
Note: Hidden from TypeDocs: Each of the logLevels (except NONE) corresponds to a method with the same name in lowercase (eg
.warn()
etc), along with.warn1()
and.willWarn()
. These methods are also bound to the instance, so you can also call asconst warn = l.warn; warn('foo');`` instead of
l.warn('foo')`.For example
All of these are hidden from TypeDocs for brevity.