This class is used to log events to a file and the output console.
Static variables
staticfinalread onlyLEVEL_DEBUG:Int = 3
Writes detailed messages of all levels. Masking of sensitive data is disabled in this level.
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
getHandlers():Collection<LoggerHandler>
Returns:
The defined handlers for this logger. Do not modify this collection.
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.
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: |
---|---|
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: |
---|---|
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: |
---|---|
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: |
---|---|
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: |
---|---|
table | Table to log. Rows are formatted to appear as a table. |