Loxer - v3.0.0
    Preparing search index...

    Interface LogMethods

    interface LogMethods {
        log(message?: unknown, ...props: unknown[]): void;
        warn: LevelMethods;
        info: LevelMethods;
        debug: LevelMethods;
        error(error: ErrorType, ...props: unknown[]): void;
        namedError(name: string, message: string, ...props: unknown[]): void;
        open(message?: unknown, ...props: unknown[]): OpenedLox;
    }
    Index
        Loxer.warn('retrying the request');
    Loxer.warn.open('degraded mode');
    • it is an ordinary log, emitted as an output event with kind: 'log'; no Error is created
    • an output stream that reacts to the level reads event.lox.level
        Loxer.info('user loaded');
    Loxer.info.open('loading user');

    'info' is the level LogMethods.log and LogMethods.open use themselves, so Loxer.info(...) writes the same log as Loxer.log(...) and Loxer.info.open(...) the same box as Loxer.open(...).

        Loxer.debug('cache miss');
    Loxer.debug.open('recalculating');

    'debug' is the last level a module reaches, so a module has to ask for it with devLevel: 'debug'; the built-in modules stop at 'info'.

    •     Loxer.log('Hello World');
      
      • it is cached until the logger is initialized
      • it won't proceed any output if Loxer is disabled
      • the visible log reaches LoxerOptions.output when the initialization supplied one
      • without an output stream, development renders the log to the console and production is silent
      • it logs at level 'info', exactly like Loxer.info()
      • can be chained with .highlight().log(...) or .h().log(...) to highlight the log
      • can be chained with .module().log(...) or .m().log(...) to assign a module to the log - otherwise it's NONE
      • all functions can be chained in combination and different order like: Loxer.h().m('Account').log(...)
      • for another LogLevel use Loxer.warn(), Loxer.debug() or Loxer.error()
          Loxer.log('restoring order', payment, cart);
      
      • every value after the message is attached to the log as one of its props, in order, and reaches the output stream and history unchanged
      • attaching props renders nothing. Chain Loxer.printProps() (or Loxer.pp()) to have the built-in output render them
      • the message may be of any type. A primitive is stringified, a non-primitive renders as one compact line, so Loxer.log(payment) reads instead of printing [object Object]

      Parameters

      • Optionalmessage: unknown

        to log, of any type

      • ...props: unknown[]

        any number of values to attach to the log

      Returns void

    •     Loxer.error(new Error('Goodbye World!'));
      
      • it is cached until the logger is initialized
      • it won't proceed any output if Loxer is disabled
      • the error reaches LoxerOptions.output as an event with kind: 'error' when one is supplied
      • without an output stream, development renders the error to the console and production is silent
      • the given Error will be appended to the output error
      • if the message is of type string | number | boolean | object, then a new Error(message.toString()) will be created and appended
      • all opened logs that were not closed until the error occurred will be appended to the error outputLog
      • a history of logs will be appended if enabled
      • can be chained with .module().error(...) or .m().error(...) to assign a module to the error - otherwise it's NONE
      • chaining with .highlight().error(...) or .h().error(...) does not color the message differently but append the stack to the default console output
      • errors are output whatever LogLevel their module allows, so a module at devLevel: 'error' reports its errors and nothing else. The emitted log carries level: 'error'.
      • there is no Loxer.error.open(): an error is a single event rather than a box (see BoxLevel)
      • position 0 is always the error, never a message: every value after it is attached as one of the log's props

      Parameters

      • error: ErrorType

        an Error or string | number| boolean | object (converted to an Error)

      • ...props: unknown[]

        any number of values to attach to the log

      Returns void

    •     Loxer.namedError('CheckoutError', 'the cart was empty', cart);
      
      • behaves exactly like LogMethods.error otherwise
      • the error's message is the given message alone
      • to wrap an error that was caught, name it explicitly: Loxer.error(new NamedError(name, message, caught), ...props)

      Parameters

      • name: string

        the Error.name of the created error

      • message: string

        the Error.message of the created error

      • ...props: unknown[]

        any number of values to attach to the log

      Returns void

    •     const loxId = Loxer.open('Open World!')
      
      • the log will get a box layout.
      • it returns an id (typeof number) that can be used with Loxer.of(id) to assign other logs to it
      • it is cached until the logger is initialized
      • it won't proceed any output if Loxer is disabled
      • the visible opening log reaches LoxerOptions.output when the initialization supplied one
      • without an output stream, development renders the log to the console and production is silent
      • can be chained with .highlight().open(...) or .h().open(...) to highlight the log
      • it opens the box at level 'info'. For another level use that level's .open(), e.g. Loxer.debug.open(...) — see LevelMethods
      • can be chained with .module().open(...) or .m().open(...) to assign a module to the log - otherwise it's NONE
      • all functions can be chained in combination and different order like: Loxer.h().m('Account').debug.open(...)

      Parameters

      • Optionalmessage: unknown

        to log, of any type

      • ...props: unknown[]

        any number of values to attach to the log

      Returns OpenedLox