This class is a utility for logging messages to the console and/or a log file. It supports different log levels ('NONE', 'DEBUG', 'INFO', 'WARN', 'ERROR') for both console and file logging. It also supports color formatting for console messages. Different colors can be specified for each log level.

Hierarchy

  • Log

Constructors

Properties

consoleLogLevel: LogLevel

The log level for console output. Can be 'NONE', 'DEBUG', 'INFO', 'WARN', or 'ERROR'.

debugToConsole: boolean

Whether to debug info to console.

debugToFile: boolean

Whether to log debug info to the logfile.

errorToConsole: boolean

Whether to log errors to console.

errorToFile: boolean

Whether to log errors to the logfile.

fileLogLevel: LogLevel

The log level for the logfile. Can be 'NONE', 'DEBUG', 'INFO', 'WARN', or 'ERROR'.

infoToConsole: boolean

Whether to log info to console.

infoToFile: boolean

Whether to log info to the logfile.

logDirpath: string

The directory path of the log file.

timezone: number

A negative or positive integer representing the timezone offset from UTC, in hours.

warnToConsole: boolean

Whether to log warnings to console.

warnToFile: boolean

Whether to log warnings to the logfile.

optionDefaults: Required<ILogOptions> = ...

Default options for creating new instances.

Accessors

Methods

  • Prints a given number of lines with dashes to the console.

    Parameters

    • numLines: number = 1

      The number of dash lines to print.

    • width: number = 80

      The number of dashes per line.

    Returns void

    Remarks

    This is not logged to the log file.

  • Logs a debug message the console.

    Type Parameters

    • T

    Parameters

    • data: T

      The message to print to console.

    • Optional depth: number

      The depth to which to print object properties.

    Returns T

  • Delete log files older than the specified number of days.

    Parameters

    • deleteFilesOlderThan: number = 0

      The maximum age of log files in days. If not specified, no files will be deleted.

    Returns void

  • Logs a error message to the console.

    Type Parameters

    • T

    Parameters

    • error: Error | T

      The Error object or message to print to console.

    Returns Error | T

  • Get the current instance's properties.

    Returns {
        consoleLogLevel: LogLevel;
        debugToConsole: boolean;
        debugToFile: boolean;
        errorToConsole: boolean;
        errorToFile: boolean;
        fileLogLevel: LogLevel;
        infoToConsole: boolean;
        infoToFile: boolean;
        logDirpath: string;
        logFilepath: string;
        timezone: number;
        warnToConsole: boolean;
        warnToFile: boolean;
    }

    • consoleLogLevel: LogLevel
    • debugToConsole: boolean
    • debugToFile: boolean
    • errorToConsole: boolean
    • errorToFile: boolean
    • fileLogLevel: LogLevel
    • infoToConsole: boolean
    • infoToFile: boolean
    • logDirpath: string
    • logFilepath: string
    • timezone: number
    • warnToConsole: boolean
    • warnToFile: boolean
  • Logs an info message the console.

    Type Parameters

    • T

    Parameters

    • data: T

      The message to print to console.

    • Optional depth: number

      The depth to which to print object properties.

    Returns T

  • This function is used to print the events emitted by an EventEmitter.

    Parameters

    • emitter: EventEmitter

      The EventEmitter that is emitting the events.

    • options: ILogEmitterEventsOptions = {}

      Options for logging the events.

    Returns void

    Remarks

    This function allows you to see what events are being emitted by an EventEmitter at runtime.

  • Write log entry to logfile

    Type Parameters

    • T

    Parameters

    • loglevel: LogLevel

      The log level.

    • data: Error | T

      The message to print to console.

    Returns void

  • Prints a given number of blank lines to the console.

    Parameters

    • numLines: number = 10

      The number of blank lines to print.

    Returns void

    Remarks

    This is not logged to the log file.

  • Logs a warning message to the console.

    Type Parameters

    • T

    Parameters

    • data: T

      The message to print to console.

    • Optional depth: number

    Returns T

Generated using TypeDoc