Loxer - v3.0.0
    Preparing search index...

    Interface LoxerOptions<M>

    Options for the Loxer.init method

    The type parameter carries the concrete LoxerOptions.modules object and is inferred, so LoxerOptions can be named without it - as the target of a const options = { ... } satisfies LoxerOptions, for example.

    interface LoxerOptions<M extends LoxerModules = RegisteredModules> {
        modules?: M;
        dev?: boolean;
        output?: LoxerOutputStream;
        config?: LoxerConfig;
        defaultLevels?: { devLevel: LogLevel; prodLevel: LogLevel };
    }

    Type Parameters

    Index
    modules?: M

    an exemplary module "Persons" would look like this:

      PERS: { fullName: 'Persons', color: '#0ff', devLevel: 'debug', prodLevel: 'warn' }
    
    • the key PERS will be used to reference the module in the logs and is kept short for laziness
    • the fullName will be (possibly sliced - see LoxerConfig.moduleTextSlice) displayed as the very first string at the output
    • the color will be applied to the module name and its box layout
    • the levels say how far down the LogLevel list this module logs: a module at 'info' logs 'error', 'warn' and 'info' logs and stops before 'debug'

    Some default modules will be set and can be overwritten here:

    will be automatically set when there is no .module(...) chained on Loxer.log(), Loxer.open() or Loxer.of() when the opening log had no module too. The default is defined as:

      NONE: { fullName: '', color: '#fff', devLevel: 'info', prodLevel: 'error' }
    

    This module will not have a module name or a box layout at the output.

    will be automatically set when Loxer.log() or Loxer.open() logs are chained with an empty .module(). The default is defined as:

      DEFAULT: { fullName: '', color: '#fff', devLevel: 'info', prodLevel: 'error' }
    

    This module will have an empty module name, but a box layout at the output.

    will be automatically set when any given module does not exist (as a key) in the given LoxerOptions.modules in the Loxer.init(options). This module is a visual indicator for misspelled or missing moduleIds. Additionally this module is serves as a fallback mechanism and should therefore never be overwritten with undefined! The default is defined as:

      INVALID: { fullName: 'INVALIDMODULE', color: '#f00', devLevel: 'info', prodLevel: 'error' }
    

    This module will have a moduleName (INVALIDMODULE), but no box layout at the output.

    The accepted ids follow the LoxerModuleRegistry: while it is empty, every module id is an ordinary string. Register the modules of your project and this object has to define exactly them - see RegisteredModules.

    dev?: boolean

    determines if Loxer is running in a development or production environment.

    • you can pass any boolean expression here
    • process.env.NODE_ENV === 'development' is common for NodeJS
    • __DEV__ is common for react-native
    • defaults to process.env.NODE_ENV === 'development'

    Receives every visible log and error as a typed output event. When it is absent, Loxer renders development events to the console and keeps production events silent.

    config?: LoxerConfig

    The Configuration of Loxer.

    defaultLevels?: { devLevel: LogLevel; prodLevel: LogLevel }

    The levels the default modules NONE and DEFAULT log up to, in production or development. If you want them set differently, override those modules in the modules option.

    • they default to devLevel: 'info' and prodLevel: 'error'

    Type Declaration

    • devLevel: LogLevel

      the level to log up to in development mode

    • prodLevel: LogLevel

      the level to log up to in production mode