Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Logger

Static singleton that represents the logging facility for Excalibur. Excalibur comes built-in with a ConsoleAppender and ScreenAppender. Derive from IAppender to create your own logging appenders.

Example: Logging

// set default log level (default: Info)
ex.Logger.getInstance().defaultLevel = ex.LogLevel.Warn;
// this will not be shown because it is below Warn
ex.Logger.getInstance().info("This will be logged as Info");
// this will show because it is Warn
ex.Logger.getInstance().warn("This will be logged as Warn");
// this will show because it is above Warn
ex.Logger.getInstance().error("This will be logged as Error");
// this will show because it is above Warn
ex.Logger.getInstance().fatal("This will be logged as Fatal");

Hierarchy

  • Logger

Index

Constructors

constructor

  • Returns Logger

Properties

Private _appenders

_appenders: IAppender[] = []

defaultLevel

defaultLevel: LogLevel = LogLevel.Info

Gets or sets the default logging level. Excalibur will only log messages if equal to or above this level. Default: LogLevel.Info

Static Private _instance

_instance: Logger = null

Methods

Private _log

  • _log(level: LogLevel, args: any[]): void
  • Logs a message at a given LogLevel

    Parameters

    • level: LogLevel

      The LogLevel`to log the message at

    • args: any[]

      An array of arguments to write to an appender

    Returns void

addAppender

  • Adds a new IAppender to the list of appenders to write to

    Parameters

    Returns void

clearAppenders

  • clearAppenders(): void
  • Clears all appenders from the logger

    Returns void

debug

  • debug(...args: Array<any>): void
  • Writes a log message at the LogLevel.Debug level

    Parameters

    • Rest ...args: Array<any>

      Accepts any number of arguments

    Returns void

error

  • error(...args: Array<any>): void
  • Writes a log message at the LogLevel.Error level

    Parameters

    • Rest ...args: Array<any>

      Accepts any number of arguments

    Returns void

fatal

  • fatal(...args: Array<any>): void
  • Writes a log message at the LogLevel.Fatal level

    Parameters

    • Rest ...args: Array<any>

      Accepts any number of arguments

    Returns void

info

  • info(...args: Array<any>): void
  • Writes a log message at the LogLevel.Info level

    Parameters

    • Rest ...args: Array<any>

      Accepts any number of arguments

    Returns void

warn

  • warn(...args: Array<any>): void
  • Writes a log message at the LogLevel.Warn level

    Parameters

    • Rest ...args: Array<any>

      Accepts any number of arguments

    Returns void

Static getInstance

  • Gets the current static instance of Logger

    Returns Logger