a logging class that uses configuration to determine what should be logged to the console and formats the logging output to indicate the source of the logging data. Configuration for this class can be passed in directly or specified in aftconfig.json like:

// aftconfig.json
{
...
"logLevel": "info"
...
}

NOTE: this should only be used in cases where using ReportingManager would not be reasonable such as inside core components of AFT; otherwise you should use a ReportingManager instance instead

Hierarchy

  • AftLogger

Constructors

Properties

Accessors

Methods

Constructors

Properties

aftCfg: AftConfig
loggerName: string

a name unique to a given AftLogger instance intended to uniquely identify output by the associated class doing the logging

Accessors

  • get logLevel(): "trace" | "debug" | "info" | "step" | "warn" | "pass" | "fail" | "error" | "none"
  • allows for filtering out of erroneous information from logs by assigning values to different types of logging. the purpose of each log level is as follows:

    • trace - used by AFT internal systems or debug events that would be very chatty (for ex: occur within a loop)
    • debug - used for debug logging that does not run within a loop or at a high frequency
    • info - used for informational events providing current state of a system
    • step - used within a test to denote where within the test steps we are
    • warn - used for unexpected errors that are recoverable
    • pass - used to indicate the success of a test expectation or assertion
    • fail - used to indicate the failure of a test expectation or assertion
    • error - used for unexpected errors that are not recoverable
    • none - used when no logging is desired (disables logging)

    Returns "trace" | "debug" | "info" | "step" | "warn" | "pass" | "fail" | "error" | "none"

Methods

  • formats the passed in LogMessage.message based on the passed in options

    Parameters

    • logObj: LogMessageData

      a LogMessage object containing the level, name and message to be formatted into a console-friendly log string

    Returns string

    the formatted log string

  • function will check that the level is greater or equal to the current configured logLevel and if it is, will send the name, level and message to the console. if the args array is included and has a length greater than 0 each item will be converted to a string using JSON.stringify(...) and appended to the message

    Parameters

    • data: LogMessageData

      a LogMessageData object containing details of the log message, level, name and any additional arguments to be logged

    Returns void

  • applies a colour based on the supplied level and outputs the message to the console using console.log in that colour

    NOTE:

    calling this function directly will bypass checking the level to see if the message should actually be logged and simply outputs to the console

    Parameters

    • level: "trace" | "debug" | "info" | "step" | "warn" | "pass" | "fail" | "error" | "none"

      a valid {LogLevel} like 'warn' or 'trace'

    • message: string

      the message string to log to console

    Returns void

Generated using TypeDoc