Logger Library
This library implements logging-behaviour that's useful especially for debugging in comet_pdf's log-file. Configurable Loglevels match the ones in comet. In the log.xml-file within the comet-project-folder Loglevels for different categories can be pre-configured. Current default-level is INFO. Current default categories are:
- com.priint.cometpdf: globally for all logging in comet (internal and scripting)
- com.priint.cometpdf.python: for instances of the
Logger-object of this library - com.priint.cometpdf.wlog: for python-function
comet.wlog, cscript-funtionwlog
Using this library Loglevels can be changed for comet globally, all Logger-objects below the python-category or individual categories based on the Logger-instance's prefix.
Upon initialization of the project in a rendering a script checks whether the rendering is executed with the trace-profile or whether the current rendering is a redelivery due to a failure and sets the loglevel to Trace globally, to improve debugging possibilities.
Enums
Logger.LogLevel
| Name | Level (int) |
|---|---|
FATAL | 100 |
WARNING | 200 |
INFO | 300 (default for logging-calls) |
DEBUG | 400 |
TRACE | 500 |
Methods
Logger(..)
(prefix = "", level = None, user_interaction = False)
Initializes an instance of the Logger-Class
| Parameters: | prefix (str) A custom string used as prefix in subsequent logging-calls. It also determines the loggers category and therefor can influence the behaviour based on the specified loglevel. |
| level (LogLevel) A LogLevel for the logger-category of the given prefix. Calls to logging-methods adhere to that level for all subsequent Logger-instances with the same prefix or until it is changed in a Logger-instance by initialization, changing the categories loglevel ( set_log_level) or the loglevel of higher scopes (set_log_level_python or set_log_level_global). | |
| user_interaction (bool) Whether or not the logger-instance should trigger dialog-windows when a message with high Loglevel is logged (WARNING or ERROR; only when executed in InDesign). | |
| Returns: | Instance of Logger-Class |
| Return Type: | Logger |
set_log_level(...)
(level: = LogLevel.INFO)
Changes the loglevel for the current logging-category (com.priint.cometpdf.python. + logger-instance's prefix). Is applied as default in subsequent logging-calls using that category.
| Parameters: | level (LogLevel) A LogLevel from Enumerator Logger.LogLevel |
| Returns: | The Logger-instance |
| Return Type: | Logger |
set_log_level_python(...)
(level: = LogLevel.INFO)
Changes the loglevel for all logging-subcategories below the category com.priint.cometpdf.python. Is applied as default in subsequent logging-calls using the librarie's Logger-class.
| Parameters: | level (LogLevel) A LogLevel from Enumerator Logger.LogLevel |
| Returns: | The Logger-instance |
| Return Type: | Logger |
set_log_level_global(...)
(level = LogLevel.INFO)
Changes the loglevel for all logging-behaviour - applies to all logging in comet (python, cscript, internal comet-logging). Is applied as default in subsequent logging-calls using the librarie's Logger-class.
| Parameters: | level (LogLevel) A LogLevel from Enumerator Logger.LogLevel |
| Returns: | The Logger-instance |
| Return Type: | Logger |
get_log_level()
| Returns: | The loglevel previously specified in the Logger-instance. |
| Return Type: | LogLevel |
set_prefix(...)
(prefix: str = "")
Changes the string, that is used as prefix in subsequent logging-calls. It also determines the loggers category and therefor can influence the behaviour based on the specified loglevel
| Parameters: | prefix (str) A custom string |
| Returns: | The Logger-instance |
| Return Type: | Logger |
get_prefix()
| Returns: | The prefix-string previously defined in the Logger-instance. |
| Return Type: | str |
log(...)
(log_string: str, log_level = LogLevel.INFO, prefix = "")
Writes a message to comet's log-file. It adds a userspecified prefix and the current function's name in front of the message.
| Parameters: | log_string (str) The string to be written in the logfile. |
| log_level (LogLevel) A custom LogLevel (from Enumerator Logger.LogLevel) overriding the global LogLevel only during this method call. | |
| prefix (str) A custom string overriding the global prefix only during this method call. | |
| Returns: | Nothing |
log_locals(...)
(log_level = LogLevel.INFO, prefix = "")
Writes a the current function's variables to comet's log-file. It adds a userspecified prefix and the current function's name in front of the message.
| Parameters: | log_level (LogLevel) A custom LogLevel (from Enumerator Logger.LogLevel) overriding the global LogLevel only during this method call. |
| prefix (str) A custom string overriding the global prefix only during this method call. | |
| Returns: | Nothing |
log_action_parameters(...)
(log_level = LogLevel.INFO, prefix = "")
Writes a the current action's parameters to comet's log-file. For Layoutrules gParam1 - gParam4 are logged; for Placeholders all function-variables are logged. It adds a userspecified prefix and the current function's name in front of the message.
| Parameters: | log_level (LogLevel) A custom LogLevel (from Enumerator Logger.LogLevel) overriding the global LogLevel only during this method call. |
| prefix (str) A custom string overriding the global prefix only during this method call. | |
| Returns: | Nothing |