Helper class for log4ahk (Implementing layout)
Creates a pattern layout according to log4j-layout and a couple of log4ahk-specific extensions.
The following placeholders can be used within the layout string:
| %d | Current date in yyyy/MM/dd hh:mm:ss format |
| %H | Hostname |
| %m | The message to be logged |
| %M | Method or function where the logging request was issued |
| %P | pid of the current process |
| %r | Number of milliseconds elapsed from logging start to current logging event |
| %R | Number of milliseconds elapsed from last logging event to current logging event |
| %s | Name of the current script |
| %S | Fullpath of the current script |
| %V | Log level |
All placeholders can be extended with formatting instructions, just similar to format:
| %20M | Reserve 20 chars for the method, right-justify and fill with blanks if it is shorter |
| %-20M | Same as %20c, but left-justify and fill the right side with blanks |
| %09r | Zero-pad the number of milliseconds to 9 digits |
| %.8M | Specify the maximum field with and have the formatter cut off the rest of the value |
To set a layout use
logger.layout.required := "[%-5.5V] {%-15.15M}{%H} %m"| _expand( |
| ) |
Expands the placeholders with the values from the given array
| ph | associative Array containing mapping placeholder to its replacement |
Splits the layout into its tokens
The layout string is separated into its separate layout elements (tokens). For example "%8V %M" consists of two tokens: "%8V" and "%M". Each token starts with "%" and ends at the next space.
The tokens are split up into its separate parts: each token consists of three parts:
| Quantifier | All placeholders can be extended with formatting instructions, just similar to format |
| Placeholder | Placeholders are replaced with the corresponding information |
| Curlies | Curlies allow further manipulation of the placeholders |
As a result of the function, the property tokens is filled with objects, which contain the complete token as well as its single parts.
For more information, which values are allowed for quantifiers, placeholders and curlies have a look at documentation of class layout
Get/set the required layout. This layout will be used to format the logged message.
Get the tokens of the current layout
For more information see _split