Logging


On this page

    Actors can log messages at different levels, which may be useful for debugging, or emitting basic information.

    This guide focuses on invoking a logger from within an actor implementation. Click here if you want to learn more about configuring logging levels and printing output.

    Logging methods

    All actors (Actor) expose the following methods:

    • logTrace(context, message, dataCb?)
    • logDebug(context, message, dataCb?)
    • logInfo(context, message, dataCb?)
    • logWarn(context, message, dataCb?)
    • logError(context, message, dataCb?)
    • logFatal(context, message, dataCb?)

    These methods allow a log message to be emitted at the different logging levels.

    These methods require the context to be passed, and a string message. Optionally, you can pass a callback to a JSON data hash.

    Example

    Emitting a log message in an actor's run method can be done as follows:

    public run(action: IAction): Promise<IActorHttpOutput> {
      this.logInfo(action.context, 'This is a message');
      this.logInfo(action.context, 'This is another message, with data',
        () => ({ someParam: 'someValue' }));
    }