Skip to content

Class: LoggerManager


  • LoggerManager



Class Methods

Inherited Methods

None in the parent class(es).



getLevel(): string

Return the log level of the root Logger.

Returns: string


getLevelFromUserDefaults(): string

Get the level from user stored settings from the key 'AppModeler_logLevel'

Returns: string


isLogSeverityHigher(severity: string): boolean

Check if loglevel is higher than the serverity or not.


Name Type Description
severity string The severity level. Its values can be: Error, Warn, Info, Debug, Trace, Off.

Returns: boolean


isTurnedOn(): boolean

Return true if the Logger is turned on. Otherwise return false.

Returns: boolean


log(message: string, severity: string, logToConsole: boolean): Promise‹any›

Log a message, if the logger is turned on.


Name Type Default Description
message string - The message to be logged.
severity string undefined Optional. The severity of the log level for logging this message. If the severity parameter is not specified or invalid, the root log level will be used.
logToConsole boolean true -

Returns: Promise‹any›


logTraceToFile(message: string, category: string, type: number): Promise‹any›

Write a message to log file and console as well.


Name Type Default Description
message string - The message to be written.
category string - The category of the message.
type number 0 Optional, the type of the message - info, warning, error.

Returns: Promise‹any›


off(): Promise‹any›

Turn off the logger.

Returns: Promise‹any›


on(): Promise‹any›

Turn on the logger. If it has not been changed, the default log level is 'Error'.

Returns: Promise‹any›


setLevel(newLevel: string): Promise‹any›

Set the log level and update the logger state accordingly (turns it on/off).


Name Type Description
newLevel string The log level. It's values can be: Error, Warn, Info, Trace, Debug, Off.

Returns: Promise‹any›


toggle(): Promise‹any›

If the logger is turned off, then it will be turned on. Otherwise it will be turned off.

Returns: Promise‹any›


uploadLogFile(backendURL: string, applicationID: string): Promise‹any›

Upload the current set of logs (logs since the last upload) to the backend URL with app ID.


Name Type Description
backendURL string The backend URL.
applicationID string The application ID.

Returns: Promise‹any›

Static clearLog

clearLog(): void

Static function to clear log and set the LoaggerManager's status to non-initialized

Returns: void

Static getInstance

getInstance(): any

Static function to return the singleton instance of the LoggerManager. If it has not been initialized yet, it throws exception.

throws Error Throw error if calling before initilizing LoggerManager.

Returns: any

the instance of the LoggerManager .

Static init

init(logFileName: string, maxFileSizeInMegaBytes: number): void

Static initializer to initializes the LoggerManager and adds the log file handlers. Example:

LoggerManager.init("log.txt", 3)


Name Type Default Description
logFileName string "ClientLog.txt" Optional, File name of the local log file on the client device. If missing, default value is ClientLog.txt
maxFileSizeInMegaBytes number 1 Optional max file size before rollover of the local log file on the client device. The default value is 1MB. The default root log level is 'Error' according to SAP SDK.

Returns: void