Logging utilities.
Utility class for pretty printing.
Variables: | nelems – Max number of elements in a list to print. |
---|
Takes the head, mid and the tail of a list and discards the rest. For example
>>> from dautil import log_api
>>> p = log_api.Printer(nelems=3)
>>> p.compress_mid(list(range(5)))
[0, '...', 2, '...', 4]
Parameters: |
|
---|---|
Returns: | The list with discarded values replaced. |
Pretty prints a message.
A specialized file handler for the logging of software versions.
Creates a logger using a configuration file provided by the user in the current working directory. If a configuration file is not found, dautil uses basic configuration.
Parameters: | name – The name of the logger. |
---|---|
Returns: | The configured logger. |
Creates a configurable logger. The environment variable DAUTIL_LOGGER controls whether the logger is enabled. If the value of the variable is *, then all loggers will be enabled, otherwise the calling function name is matched against DAUTIL_LOGGER. Enabling/disabling the logger may be influenced by an underlying framework.
Returns: | A configurable logger. |
---|
Creates a logger using an internal configuration file.
Parameters: | name – The name of the logger. |
---|---|
Returns: | The configured logger. |
Logs the versions of imported modules in a best effort fashion. Some common modules are excluded.
Parameters: |
|
---|---|
Returns: | A dictionary with modules as keys and versions as values. |
Helper function which shortens a module name using the first occurrence of a dot. For example pandas.io.wb is shortened to pandas.
Parameters: | module_name – The name of the module. |
---|---|
Returns: | The shortened name. |
>>> from dautil import log_api
>>> log_api.shorten('pandas.io.wb')
'pandas'