Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface LogMethods

Hierarchy

  • LogMethods

Methods

Methods

log

  •     Loxer.log('Hello World');
    

    Works similar to console.log(), but:

    • it is cached until the logger is initialized
    • it won't proceed any output if Loxer is disabled
    • the output will be streamed out to the LoxerOptions.callbacks declared in Loxer.init(options)
    • if no callbacks are given at the initialization, all logs will be logged with console.log(message, item), but only in development mode
    • can be chained with .highlight().log(...) or .h().log(...) to highlight the log
    • can be chained with .level().log(...) or .l().log(...) to set a level to the log - otherwise it's 1 (high)
    • 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().l(2).m('Account').log(...)

    Parameters

    • message: string

      to log

    • Optional item: ItemType

      to append

    • Optional itemOptions: ItemOptions

      to configure the (default) output of the item

    Returns void

error

  •     Loxer.error(new Error('Goodbye World!'));
    

    Works similar to console.error(), but:

    • it is cached until the logger is initialized
    • it won't proceed any output if Loxer is disabled
    • the errors will be streamed out to the LoxerOptions.callbacks declared in Loxer.init(options)
    • if no callbacks are given at the initialization, all errors will be logged with console.log(error), but only in development mode
    • 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
    • chaining with .level().error(...) or .l().error(...) will not take any effect on the error log (except that level will be a property of the output)

    Parameters

    • error: ErrorType

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

    • Optional item: ItemType

      to append

    • Optional itemOptions: ItemOptions

      to configure the (default) output of the item

    Returns void

open

  •     const loxId = Loxer.open('Open World!')
    

    Opens a boxed log to assign other logs / errors to it.

    • 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 output will be streamed out to the LoxerOptions.callbacks declared in Loxer.init(options)
    • if no callbacks are given at the initialization, all logs will be logged with console.log(message, item), but only in development mode
    • can be chained with .highlight().open(...) or .h().open(...) to highlight the log
    • can be chained with .level().open(...) or .l().open(...) to set a level to the log - otherwise it's 1 (high)
    • 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().l(2).m('Account').open(...)

    Parameters

    • message: string

      to log

    • Optional item: ItemType

      to append

    • Optional itemOptions: ItemOptions

      to configure the (default) output of the item

    Returns OpenedLox

of

  •     // this has to be done before:
        const id = Loxer.open('opening message');
        // assign a log:
        Loxer.of(id).add('next step is reached');
        // assign an error:
        Loxer.of(id).error('something went wrong');
        // close the log box:
        Loxer.of(id).close('closing message');
    

    Provides chained methods to add logs / errors and close the box of the given id's opened log.

    • assigned logs / errors will receive a time consumption since the box was opened
    • it won't proceed any output if Loxer is disabled
    • can be chained with .highlight().log(...) or .h().log(...) to highlight the log TODO level changes
    • can be chained with .level().of(...) or .l().of(...) to set a level to the logs - otherwise it's 1 (high)
    • chaining with .module().of(...) or .m().of(...) to assign modules will take no effect though assigned modules will always adapt the module of the opening log
    • all functions can be chained in combination and different order like: Loxer.h().l(2).m('Account').log(...)

    Returned functions

    • add: (message: string, item?: any) - assigns a single log to the box
    • error: (error?: Error | string) - assigns an error log to the box
    • close: (message: string, item?: any) - assigns a log to the box, that also closes the box (and its box layout)
    • ATTENTION: calling add(), error() or close() after closing the box, the log will not be appended to the box but logged anyways with a Warning

    Parameters

    • id: number | OpenedLox

      the id returned from Loxer.open() to reference this log to

    Returns OfLoxes

Generated using TypeDoc