The LogZen Options interface

Note: it is a class only for validation purposes via class-validator, but it's not meant to be instantiated.

Hierarchy (view full)

Constructors

Properties

loggerName?: string

You can pass a custom name, eg "My LogZen".

It can be a "path" where it resides, physically or conceptually

eg /controllers/customer.controller

Note that the physical (relative) path is automatically printed on the Header, if loggerName is not present.

It's best to leave this undefined and use PathReplacements

@default: undefined, in which case the Header prints the resolved filename where LogZen is created in.

Where & how to print / output log messages and info.

header?: boolean | Header

Customize Header options, or disable with header: false

Possible values:

  • true: prints a default header

  • Header object: Header enabled with separate settings within.

  • false: Header is disabled

Example:

Issuing a l.warn('Hello World') will output something like:

    ```
      WARN (src/examples-docs/logzen-examples-docs-tests-playground): Hello World

    ```

With header: false, it just prints

    ```
      Hello World"
    ```

@default: header object with defaults

stackDepthCreated?: number

If using LogZen wrapped (eg subclass, proxy etc) inside another MyLogger, it will resolve to wrong filepath, e.g. the wrapped MyLogger as the path it as created.

Adjust accordingly ;-)

stackDepthCalled?: number

If using LogZen wrapped (eg Proxied) inside another MyLogger, it will report itself (i.e the wrapped MyLogger) as the path it was called to l.log() from (eg via options.header.resolvedFromCall).

Adjust accordingly ;-)

logLevel?:
    | "error"
    | "fatal"
    | "critical"
    | "notice"
    | "trace"
    | "warn"
    | "log"
    | "ok"
    | "info"
    | "verbose"
    | "debug"
    | "silly"
    | ELogLevel
    | "NONE"

The logLevel to allow, i.e what logging severity is in effect.

See logLevel

@default: undefined, but debug is implicitly enforced (hard coded)

tableLogLevel?:
    | "error"
    | "fatal"
    | "critical"
    | "notice"
    | "trace"
    | "warn"
    | "log"
    | "ok"
    | "info"
    | "verbose"
    | "debug"
    | "silly"
    | ELogLevel
    | "NONE"

Configure the logLevel of the table() method.

@default: ELogLevel.LOG

debugLevel?: number

The debugLevel is the debug-only severity to allow.

It's an arbitrary number of a range of your choosing, but 0-100 is recommended.

undefined, so l.debug('something') with no debugLevel will print (if logLevel allows debug).

traceLevel?: number

The traceLevel is the .trace()-only granular severity to allow.

It's an arbitrary number of a range of your choosing, but 0-100 is recommended.

undefined, so l.trace('something') with no traceLevel will print (if logLevel allows tracetrace).

colors?: boolean

Whether to use colors in the whole output.

It also turns off stringColors.

If inspect.colors is missing in an atomic options set or update, it inherits this one (if present).

@default: true

stringColors?: boolean

Whether to use the LogLevel color on (top level) strings

@default: true

trace?: TraceOptions

The TraceOptions to use

inspect?: boolean | LogZenInspectOptions

The LogZenInspectOptions to use

If false, it disables inspect completely, and uses print

print?: PrintOptions

The PrintOptions to use, if inspect is false

printMode?: "inspect" | "print"
raw?: boolean

Whether to pass the raw values of the argsToLog, without any formatting (inspect, colors, console interpolation etc).

Disables all relevant options (colors, inspect & console style interpolation).

Useful for JSON output.

@default: undefined, i.e false

kids?: Omit<Options, "kids">[]

Add & maintain a list of kids loggers, using these Options.

These kid loggers are fully managed by LogZen, updating them via options and not programmatically.

Kids rules are:

  • When path options merge, kids loggers Options from nested paths (eg /my/app/nested/path) are added to those in above paths (eg /my/app), not replacing those above (as it happens with other options).

  • Null is a special value: if {kids: null} or {kids: [null, {loggerName: 'a kid'}]}, are not inheriting those before the null, up in the chain to root.

  • Kids can't have their own kids (i.e no nested kids / grandkids). This because it's not tested and could lead to unexpected results. It will throw an Error if trying to do so.

  • When kids's options change, the kids are recreated with these new options (i.e no partial options merging with kids options)