This class is used to log events to a file and the output console.

Static variables

@:value(3)staticfinalread onlyLEVEL_DEBUG:Int = 3

Writes detailed messages of all levels. Masking of sensitive data is disabled in this level.

@:value(0)staticfinalread onlyLEVEL_ERROR:Int = 0

Only writes error level messages.

@:value(2)staticfinalread onlyLEVEL_INFO:Int = 2

Only writes error & info level messages.

@:value(1)staticfinalread onlyLEVEL_WARNING:Int = 1

Only writes error & warning level messages.

Constructor

new(config:LoggerConfig)

Creates a new Logger object. You don't normally create objects of this class, since the SDK uses the default instance provided by Env.getLogger() or Env.getLoggerForRequest().

Methods

addRegExMask(expression:String):Void

Adds a new regular expression for string data masking purposes.

closeSection():Void

Closes the last opened section.

copy(request:Null<IdModel>):Logger

getFilename():String

Returns:

The last filename that was set.

getHandlers():Collection<LoggerHandler>

Returns:

The defined handlers for this logger. Do not modify this collection.

getInitialConfig():LoggerConfig

Returns:

initial logger configuration

getLevel():Int

Returns:

Int The level of the log. One of: LEVEL_ERROR, LEVEL_WARNING, LEVEL_INFO, LEVEL_DEBUG.

getMaskedFields():Collection<String>

Returns a list of fields which should be masked in http requests or responses.

getMaskedParams():Collection<String>

Returns a list of param ids whose value should be masked in logged requests.

getPath():String

Returns:

The path where logs are stored.

isBeautified():Bool

Returns:

Bool Whether the logs are written in beautified format (this is, for JSON objects use new lines and two space indentation). This method is deprecated and always returns false.

isCompact():Bool

Returns:

Bool Whether the logs are written in compact format (this is, for JSON objects only print key names or, if it has an 'id' field, only the id). This method is deprecated and always returns false.

openSection(name:String):Void

Opens a new section in the log. This will be output as a Markdown header when using this formatting, depending on the number of opened sections. For example, at the beginning of a function, a section can be opened, and closed when the function finishes.

setFilename(filename:String):Void

Sets the filename of the log. All future log messages will get printed to this file. Initially, the logger only writes to the standard output. The first time you call this method with an argument other than null, the provided name will be considered the default filename. Whenever this method is called afterwards with a null argument, output will be sent to the default file.

Filename extension must be omitted, since it is provided by the formatters used in each handler.

write(level:Int, message:String):Void

Writes a message to the log in the specified level. It adds a new line to the log after writing the message.

Parameters:

level

Message level. One of: LEVEL_ERROR, LEVEL_WARNING, LEVEL_INFO, LEVEL_DEBUG.

message

Message to log. The message is not formatted.

writeBlock(level:Int, block:String):Void

Writes a block to the log in the specified level. It adds a new line to the log after writing the block.

Parameters:

level

Message level. One of: LEVEL_ERROR, LEVEL_WARNING, LEVEL_INFO, LEVEL_DEBUG.

block

Block of text to log. Lines in the text are formatted to appear as a block.

writeCodeBlock(level:Int, code:String, language:String):Void

Writes a code block to the log in the specified level. It adds a new line to the log after writing the block.

Parameters:

level

Message level. One of: LEVEL_ERROR, LEVEL_WARNING, LEVEL_INFO, LEVEL_DEBUG.

code

Code to log. Text is formatted to appear as a code block.

language

Language used in the block. For example, "json". Can be an empty string.

writeList(level:Int, list:Collection<String>):Void

Writes a list to the log in the specified level. It adds a new line to the log after writing the list.

Parameters:

level

Message level. One of: LEVEL_ERROR, LEVEL_WARNING, LEVEL_INFO, LEVEL_DEBUG.

list

List to log. Lines are formatted to appear as a list.

writeTable(level:Int, table:Collection<Collection<String>>):Void

Writes a table to the log in the specified level. The first row should contain the table header. It adds a new line to the log after writing the list.

Parameters:

level

Message level. One of: LEVEL_ERROR, LEVEL_WARNING, LEVEL_INFO, LEVEL_DEBUG.

table

Table to log. Rows are formatted to appear as a table.