rm_lite.utils.logging¶
Logging module for arrakis
Attributes¶
Classes¶
Formatter instances are used to convert a LogRecord to text. |
|
Output stream for TQDM which will output to logger module instead of |
|
Multiset of active requested levels backing quiet_logs (avoids module globals). |
Functions¶
|
Will construct a logger object. |
|
Temporarily raise the rm-lite logger's level to at least level. |
Module Contents¶
- class rm_lite.utils.logging.CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)¶
Bases:
logging.FormatterFormatter instances are used to convert a LogRecord to text.
Formatters need to know how a LogRecord is constructed. They are responsible for converting a LogRecord to (usually) a string which can be interpreted by either a human or an external system. The base Formatter allows a formatting string to be specified. If none is supplied, the style-dependent default value, “%(message)s”, “{message}”, or “${message}”, is used.
The Formatter can be initialized with a format string which makes use of knowledge of the LogRecord attributes - e.g. the default value mentioned above makes use of the fact that the user’s message and arguments are pre- formatted into a LogRecord’s message attribute. Currently, the useful attributes in a LogRecord are described by:
%(name)s Name of the logger (logging channel) %(levelno)s Numeric logging level for the message (DEBUG, INFO,
WARNING, ERROR, CRITICAL)
- %(levelname)s Text logging level for the message (“DEBUG”, “INFO”,
“WARNING”, “ERROR”, “CRITICAL”)
- %(pathname)s Full pathname of the source file where the logging
call was issued (if available)
%(filename)s Filename portion of pathname %(module)s Module (name portion of filename) %(lineno)d Source line number where the logging call was issued
(if available)
%(funcName)s Function name %(created)f Time when the LogRecord was created (time.time()
return value)
%(asctime)s Textual time when the LogRecord was created %(msecs)d Millisecond portion of the creation time %(relativeCreated)d Time in milliseconds when the LogRecord was created,
relative to the time the logging module was loaded (typically at application startup time)
%(thread)d Thread ID (if available) %(threadName)s Thread name (if available) %(taskName)s Task name (if available) %(process)d Process ID (if available) %(message)s The result of record.getMessage(), computed just as
the record is emitted
- format(record: logging.LogRecord) str¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- FORMATS¶
- format_str = '%(module)s.%(funcName)s: %(message)s'¶
- class rm_lite.utils.logging.TqdmToLogger(logger: logging.Logger, level: int = logging.INFO)¶
Bases:
io.StringIOOutput stream for TQDM which will output to logger module instead of the StdOut.
- flush() None¶
Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
- write(buf: str) int¶
Write string to file.
Returns the number of characters written, which is always equal to the length of the string.
- buf = ''¶
- level = None¶
- logger = None¶
- class rm_lite.utils.logging._QuietState¶
Multiset of active requested levels backing quiet_logs (avoids module globals).
- level_before_quiet = 0¶
- lock¶
- rm_lite.utils.logging.get_logger(name: str = 'rmtools-lite', attach_handler: bool = True) logging.Logger¶
Will construct a logger object.
- Parameters:
- Returns:
The appropriate logger
- Return type:
- rm_lite.utils.logging.quiet_logs(level: int = logging.WARNING) collections.abc.Iterator[None]¶
Temporarily raise the rm-lite logger’s level to at least level.
Reentrant and thread-safe: concurrent callers (e.g. dask workers running one call per chunk, possibly requesting different levels, e.g. rmsynth_3d defaults to WARNING and run_rmclean to ERROR) share a multiset of active requested levels. The logger’s level is always the max (most restrictive) of whatever’s currently active, recomputed on every entry/exit, and only restored to its original value once every caller has exited. Tracking a plain reentrant depth counter instead of the actual requested levels would let a concurrent, less-restrictive request silently under-suppress a stricter one running at the same time.
- rm_lite.utils.logging._quiet_state¶
- rm_lite.utils.logging.logger¶