Codeunit 70623694 EOS004 App Logger

Codeunit 70623694 EOS004 App Logger

Provides a framework for logging messages from apps to multiple underlying loggers.

Methods

Reset

procedure Reset()

Resets the logger, removing all configuration and cached data.


Initialize

procedure Initialize(AppId: Guid; Category: Text): Boolean

Initializes the logger with the specified app and category. This replaces all currently cached loggers with the configured ones.

Parameters / Return Value

  • AppId Guid

    The app id.

  • Category Text[]

    The category.

  • Returns Boolean

    true if the logger was actually initialized, false if it already was initialized.


ClearLoggers

procedure ClearLoggers()

Removes all loggers from the list of loggers.


AddLogger

procedure AddLogger(LoggerType: Enum "EOS004 App Logger Type"; ServiceConfigCode: Code[20]; DiagnosticsKey: Text[64])

Creates, initializes and then adds a logger of the given type and the given service configuration to the list of loggers.

Parameters / Return Value

  • LoggerType Enum "EOS004 App Logger Type"

    The type of logger to add.

  • ServiceConfigCode Code[20]

    The service configuration code for the logger to add.

  • DiagnosticsKey Text[64]

    The diagnostics key for the logger to add.


AddLogger

procedure AddLogger(Logger: Interface "EOS004 IAppLogger")

Manually adds the given logger to the list of loggers. This logger is expected to be already initialized.

Parameters / Return Value

  • Logger Interface "EOS004 IAppLogger"

    The logger to add.


AddApplicationInsights

procedure AddApplicationInsights(ConnectionString: Text; DiagnosticsKey: Text[64])

Manually adds an Application Insights logger to the list of loggers. This requires the current instance to be initialized first.

Parameters / Return Value

  • ConnectionString Text[]

    The connection string for the Application account.

  • DiagnosticsKey Text[64]

    The diagnostics key to use.


Initialize

procedure Initialize(App: ModuleInfo; Category: Text): Boolean

Initializes the logger with the specified app and category. This replaces all currently cached loggers with the configured ones.

Parameters / Return Value

  • App ModuleInfo

    The app.

  • Category Text[]

    The category.

  • Returns Boolean

    true if the logger was actually initialized, false if it already was initialized.


AutoFlushLimit

procedure AutoFlushLimit(): Integer

Specifies whether the logger should automatically flush after a certain number of log entries.

Parameters / Return Value

  • Returns Integer

    The current value.


AutoFlushLimit

procedure AutoFlushLimit(NewValue: Integer)

Specifies whether the logger should automatically flush after a certain number of log entries. If you want to disable auto-flushing, set this to 0.

Parameters / Return Value

  • NewValue Integer

InitializeFromCaller

procedure InitializeFromCaller(Category: Text): Boolean

Initializes the logger from the calling app and the given category. This replaces all currently cached loggers with the configured ones.

Parameters / Return Value

  • Category Text[]

    The category.

  • Returns Boolean

    true if the logger was actually initialized, false if it already was initialized.


LogMessage

procedure LogMessage(EventId: Text; Message: Text)

Logs a message to all underlying loggers with the specified event id and message.

Parameters / Return Value

  • EventId Text[]

    The event id.

  • Message Text[]

    The message.


LogMessage

procedure LogMessage(EventId: Text; Message: Text; Payload: Dictionary of [Text, Text])

Logs a message to all underlying loggers with the specified event id and message. Includes additional properties through the payload.

Parameters / Return Value

  • EventId Text[]

    The event id.

  • Message Text[]

    The message.

  • Payload Dictionary[Text,Text]

    The additional properties payload.


LogMessage

procedure LogMessage(EventId: Text; Message: Text; Verbosity: Verbosity; DataClassification: DataClassification; Scope: TelemetryScope)

Logs a message to all underlying loggers with the specified properties.

Parameters / Return Value

  • EventId Text[]

    The event id.

  • Message Text[]

    The message.

  • Verbosity Verbosity

    The verbosity.

  • DataClassification DataClassification

    The data classification.

  • Scope TelemetryScope

    The scope.


LogMessage

procedure LogMessage(EventId: Text; Message: Text; Verbosity: Verbosity; DataClassification: DataClassification; Scope: TelemetryScope; Payload: Dictionary of [Text, Text])

Logs a message to all underlying loggers with the specified properties.

Parameters / Return Value

  • EventId Text[]

    The event id.

  • Message Text[]

    The message.

  • Verbosity Verbosity

    The verbosity.

  • DataClassification DataClassification

    The data classification.

  • Scope TelemetryScope

    The scope.

  • Payload Dictionary[Text,Text]

    The additional properties payload.


AssertInitialized

procedure AssertInitialized()

Ensures that this instance has been initialized. If it hasn’t, a runtime error will be thrown.


IsEnabled

procedure IsEnabled(): Boolean

Specifies whether there exist any enabled underlying loggers. If this instance has not yet been initialized, this will always return false.

Parameters / Return Value

  • Returns Boolean

    true if there exist any enabled underlying loggers, false otherwise.


CollectLogCategories

procedure CollectLogCategories(AppId: Guid; var TempLogCategory: Record "EOS004 App Log Category")

Collects all log categories for the specified app. This method can be called even if the instance has not been initialized.

Parameters / Return Value

  • AppId Guid

    The app id.

  • TempLogCategory Record "EOS004 App Log Category"

    Will contain all categories for the given app.


Flush

procedure Flush(): Integer

Flushes all underlying loggers.

Parameters / Return Value

  • Returns Integer

    The total number of log entries that were flushed.


Events

OnCollectLogCategories

local procedure OnCollectLogCategories(AppId: Guid; var TempLogCategory: Record "EOS004 App Log Category")

Raised when collecting log categories for the specified app. Subscribe to this to provide categories your app can log to. You must provide at least one non-empty category in order for your app to be usable by this logger framework.

Parameters / Return Value

  • AppId Guid

    The Id of the app for which categories are requested.

  • TempLogCategory Record "EOS004 App Log Category"

    The record containing the log categories for the app.



EOS Labs -