Skip to content

Class: LoggerManager

Hierarchy

  • LoggerManager

Summary

Methods

Class Methods

Inherited Methods

Currently none inherited from the parent class(es).

Methods

getLevel

getLevel(): string

Returns the log level of the root Logger.

Returns: string


getLevelFromUserDefaults

getLevelFromUserDefaults(): string

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

Returns: string


isLogSeverityHigher

isLogSeverityHigher(severity: string): boolean

Check if loglevel is higher than the serverity or not

Parameters:

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

Returns: boolean


isTurnedOn

isTurnedOn(): boolean

Return true, if the Logger is turned On. Otherwise return false.

Returns: boolean


log

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

Log a message, if the logger is turned on.

Parameters:

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

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

Write a message to log file and console as well.

Parameters:

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

off(): Promise‹any›

Turn off the logger.

Returns: Promise‹any›


on

on(): Promise‹any›

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

Returns: Promise‹any›


setLevel

setLevel(newLevel: string): Promise‹any›

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

Parameters:

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

Returns: Promise‹any›


toggle

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

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.

Parameters:

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 Throws 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);

Parameters:

Name Type Default Description
logFileName string "ClientLog.txt" Optional, file name of the local log file on the client device. The 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