Options
All
  • Public
  • Public/Protected
  • All
Menu

@alterior/logging

Index

Type aliases

LogFormat

LogFormat: string | ((event: LogEvent) => string)

LogSeverity

LogSeverity: "debug" | "info" | "warning" | "error" | "fatal"

Variables

Const DEFAULT_LISTENERS

DEFAULT_LISTENERS: LogListener[] = [ new ConsoleLogger(DEFAULT_FORMAT) ]

Let ENABLED

ENABLED: boolean = false

Functions

Const DEFAULT_FORMAT

  • DEFAULT_FORMAT(event: LogEvent): string

ReportExceptionsToConsole

  • ReportExceptionsToConsole(): (target: any, ...args: any[]) => void
  • If an exception occurs within the target method, report that exception to the console and rethrow.

    Returns (target: any, ...args: any[]) => void

      • (target: any, ...args: any[]): void
      • Parameters

        • target: any
        • Rest ...args: any[]

        Returns void

Trace

  • Trace(): (target: any, ...args: any[]) => void
  • Prints messages related to the execution of the decorated method to the console.

    • When multiple traced functions are involved, the output is indented appropriately.
    • Intercepts console messages from within the function to add appropriate indentation.
    • Records (and rethrows) exceptions thrown from within the function.
    • For methods returning promises, the promise itself is traced, printing a "Resolved" message upon completion or a "Rejected" message upon rejection.

    Note that this functionality can be enabled and disabled by configuring the tracing option when configuring this module for your application. When @Trace() is used outside of an Alterior execution context, the trace logs are always enabled, and the default log listeners are used.

    For example, given a class:

    class Thing {
    @ConsoleTrace()
    static doSomething(data : any, stuff : number) {
    console.log("ALMOST...");
    try {
    this.anotherSomething(stuff);
    } catch (e) {
    
    }
    }
    @ConsoleTrace()
    static anotherSomething(stuff : number) {
    console.log("NAH...");
    throw new Error('Uh oh');
    }
    }

    When executed, one may see:

    Thing#doSomething({"stuff":321,"other":"nice"}, 12333) {
    ALMOST...
    Thing#anotherSomething(12333) {
    NAH...
    (!!) Exception:
    Error: Uh oh
    } // [Exception] Thing#anotherSomething(12333)
    } // [Done, 6ms] Thing#doSomething({"stuff":321,"other":"nice"}, 12333)

    Returns (target: any, ...args: any[]) => void

      • (target: any, ...args: any[]): void
      • Parameters

        • target: any
        • Rest ...args: any[]

        Returns void

arrayToHash

  • arrayToHash(array: any): {}

formatArray

  • formatArray(ctx: any, value: any, recurseTimes: any, visibleKeys: any, keys: any): any[]
  • Parameters

    • ctx: any
    • value: any
    • recurseTimes: any
    • visibleKeys: any
    • keys: any

    Returns any[]

formatError

  • formatError(value: any): string

formatPrimitive

  • formatPrimitive(ctx: any, value: any): any

formatProperty

  • formatProperty(ctx: any, value: any, recurseTimes: any, visibleKeys: any, key: any, array: any): any
  • Parameters

    • ctx: any
    • value: any
    • recurseTimes: any
    • visibleKeys: any
    • key: any
    • array: any

    Returns any

formatValue

  • formatValue(ctx: any, value: any, recurseTimes: any): any
  • Parameters

    • ctx: any
    • value: any
    • recurseTimes: any

    Returns any

getTracingEnabled

  • getTracingEnabled(): boolean

hasOwn

  • hasOwn(obj: any, prop: any): any

inspect

  • Echos the value of a value. Trys to print the value out in the best way possible given the different types.

    license

    MIT (© Joyent)

    Parameters

    • obj: any

      The object to print out.

    • Optional opts: InspectOptions

      Optional options object that alters the output.

    Returns string

isBoolean

  • isBoolean(arg: any): boolean

isDate

  • isDate(d: any): boolean

isError

  • isError(e: any): boolean

isFunction

  • isFunction(arg: any): boolean

isNull

  • isNull(arg: any): boolean

isNumber

  • isNumber(arg: any): boolean

isObject

  • isObject(arg: any): boolean

isRegExp

  • isRegExp(re: any): boolean

isString

  • isString(arg: any): boolean

isUndefined

  • isUndefined(arg: any): boolean

objectToString

  • objectToString(o: any): any

reduceToSingleString

  • reduceToSingleString(output: any, base: any, braces: any): string
  • Parameters

    • output: any
    • base: any
    • braces: any

    Returns string

setTracingEnabled

  • setTracingEnabled(enabled: boolean): void

stylizeNothing

  • stylizeNothing(str: any, styleType: any): any
  • Pass the string through with no stylization.

    Parameters

    • str: any
    • styleType: any

    Returns any

stylizeWithConsoleColors

  • stylizeWithConsoleColors(str: any, styleType: any): any
  • Use console colors to style the string. Suitable for output to terminals with ANSI color support.

    Parameters

    • str: any
    • styleType: any

    Returns any

Object literals

Const CONSOLE_COLOR_STYLES

CONSOLE_COLOR_STYLES: object

boolean

boolean: string = "yellow"

date

date: string = "magenta"

null

null: string = "bold"

number

number: string = "yellow"

regexp

regexp: string = "red"

special

special: string = "cyan"

string

string: string = "green"

undefined

undefined: string = "grey"

Generated using TypeDoc