StaticcExpose the whole ansi-colors package as "c", per its convention. Useful to have with you for logging!
OptionaldebugLevel: numberOptionallogLevel: OptionaldebugLevel: numberOptionaloptions: OptionsAtConstructorOptionaldebugLevel: numberOptionaloptions: OptionsAtConstructorOptionallogLevel: OptionaldebugLevel: numberStaticupdateAdd 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
StaticaddAdd 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
StaticinspectStaticclearStatictimerStart 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).
Optionalalways: booleanrestart timer automatically when it elapses - see always restart timer
the timestamp when the timer was started (or null if always=false)
StatictimerStatictimerStops 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
StaticresetThe 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).
Optionalalways: 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.
Optionalpath: 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_actualProtectedThe actual log method for leveled log (i.e debug & trace), that all other log methods call.
OptionalargsToPrint: 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 ofl.warn('foo')`.For example
All of these are hidden from TypeDocs for brevity.