arrakis.logger ============== .. py:module:: arrakis.logger .. autoapi-nested-parse:: Logging module for arrakis .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: arrakis.logger.logger Classes ------- .. autoapisummary:: arrakis.logger.CustomFormatter arrakis.logger.TqdmToLogger arrakis.logger.UltimateHelpFormatter Functions --------- .. autoapisummary:: arrakis.logger.get_arrakis_logger Module Contents --------------- .. py:class:: CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None) Bases: :py:obj:`logging.Formatter` Formatter 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) %(process)d Process ID (if available) %(message)s The result of record.getMessage(), computed just as the record is emitted .. !! processed by numpydoc !! .. py:method:: 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. .. !! processed by numpydoc !! .. py:attribute:: FORMATS .. py:attribute:: blue :value: '\x1b[34;20m' .. py:attribute:: bold_red :value: '\x1b[31;1m' .. py:attribute:: format_str :value: '%(asctime)s.%(msecs)03d %(module)s - %(funcName)s: %(message)s' .. py:attribute:: green :value: '\x1b[32;20m' .. py:attribute:: grey :value: '\x1b[38;20m' .. py:attribute:: red :value: '\x1b[31;20m' .. py:attribute:: reset :value: '\x1b[0m' .. py:attribute:: yellow :value: '\x1b[33;20m' .. py:class:: TqdmToLogger(logger: logging.Logger | None, level: int | None = None) Bases: :py:obj:`io.StringIO` Output stream for TQDM which will output to logger module instead of the StdOut. .. !! processed by numpydoc !! .. py:method:: flush() -> None Flush write buffers, if applicable. This is not implemented for read-only and non-blocking streams. .. !! processed by numpydoc !! .. py:method:: write(buf: str) -> int Write string to file. Returns the number of characters written, which is always equal to the length of the string. .. !! processed by numpydoc !! .. py:attribute:: buf :value: '' .. py:attribute:: level :value: None .. py:attribute:: logger :value: None .. py:class:: UltimateHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None) Bases: :py:obj:`argparse.RawTextHelpFormatter`, :py:obj:`argparse.ArgumentDefaultsHelpFormatter` Help message formatter which retains formatting of all help text. Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. .. !! processed by numpydoc !! .. py:function:: get_arrakis_logger(name: str = 'arrakis', attach_handler: bool = True) -> logging.Logger Will construct a logger object. :Parameters: * **name** (*str, optional*) -- Name of the logger to attempt to use. This is ignored if in a prefect flowrun. Defaults to 'arrakis'. * **attach_handler** (*bool, optional*) -- Attacjes a custom StreamHandler. Defaults to True. :returns: The appropriate logger :rtype: logging.Logger .. !! processed by numpydoc !! .. py:data:: logger