@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

    • Parameters

      Returns Logger

    Methods

    • Check condition. Log error if condition fails

      Parameters

      • condition: boolean

        Condition to check

      • Optionalmessage: string

        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

    • Log message of given severity category, overriding Name of module logging

      Parameters

      • name: string

        Name of module logging

      • 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

      • name: string

        Name of module logging

      • condition: boolean

        Condition to check

      • Optionalmessage: string

        Message to show.

      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

      • name: string

        Name of module logging

      • message: string

        Message to show.

      • e: string | Error

        Exception object

      Returns void

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

      Parameters

      • runtime: Runtime

        Cogs.js runtime instance

      • name: string

        Name of module logging

      • category: LogCategory

        Logging category

      • message: string

        Message to show.

      Returns void