@kognifai/cogsengine
    Preparing search index...

    Class Logger

    Cogs.js logger. Passes logging information back to print function passed when creating the Cogs.js Control instance, e.g. settings.print. . Usage: class CogsClass { private Logger logger; constructor(Cogs.Runtime runtime) { this.logger = Logger.create(runtime, 'CogsClass'); } doSomething(ok: boolean) { this.logger.check(ok, 'doSomething param check'); this.logger.log(LogCategory.Info, 'Staring doing something'); try { ... } catch(err) { this.logger.exception('my code failed', err); } } }

    Index

    Constructors

    • Internal constructor

      Parameters

      Returns Logger

    Methods

    • Check condition. Log error if condition fails

      Parameters

      • condition: boolean

        Condition to check

      • message: string = "Condition failed"

        Optional Message to log if error

      Returns boolean

      Input condition.

    • Log exception. Shows passed message with exception info (optional e.message + m.stack)

      Parameters

      • message: string

        Message to show.

      • e: string | Error

        Exception object

      Returns void

    • Log message of given severity category

      Parameters

      • category: LogCategory

        Logging category

      • message: string

        Message to show.

      Returns void

    • Utility: Check condition without creating class instance. see Logger.check

      Parameters

      • runtime: Runtime

        Cogs.js runtime instance

      • source: string
      • condition: boolean

        Condition to check

      • message: string = "Condition failed"

        Optional Message to log.

      Returns boolean

      Input condition.

    • Creates new logger logging using input name as prefix in brackets, e.g. [${name}] ${message}

      Parameters

      • runtime: Runtime

        Cogs.js runtime instance

      • name: string

        Name of module logging. Shown as [Level][${name}] message.

      Returns Logger

      new instance

    • Utility: Log exception without creating class instance. see Logger.log

      Parameters

      • runtime: Runtime

        Cogs.js runtime instance

      • source: string

        Name of module logging

      • message: string

        Message to show.

      • e: string | Error

        Exception object

      Returns void

    • Root logging function

      Parameters

      • runtime: Runtime

        Cogs.js runtime instance

      • source: string

        Source of log message

      • category: LogCategory

        Logging category

      • message: string

        Message to show.

      Returns void

    • Parameters

      Returns string