:py:mod:`core.logging` ====================== .. py:module:: core.logging Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: core.logging.ViURDefaultLogger core.logging.ViURLocalFormatter Attributes ~~~~~~~~~~ .. autoapisummary:: core.logging.client core.logging.requestLogger core.logging.requestLoggingRessource core.logging.logger core.logging.EXCLUDED_LOGGER_DEFAULTS core.logging.excluded_logger core.logging.handler .. py:class:: ViURDefaultLogger Bases: :py:obj:`google.cloud.logging.handlers.CloudLoggingHandler` This is the ViUR-customized CloudLoggingHandler .. py:method:: emit(record) .. py:class:: ViURLocalFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None) Bases: :py:obj:`logging.Formatter` This is a formatter that injects console color sequences for debug output. The formatting can be modified using environment variables as follows: - VIUR_LOGGING_COLORIZATION can be either FULL (colorize full line) or DECENT (colorize debug level only) - VIUR_LOGGING_COLOR_DEBUG set debug level color - VIUR_LOGGING_COLOR_INFO set info level color - VIUR_LOGGING_COLOR_WARNING set warning level color - VIUR_LOGGING_COLOR_ERROR set error level color - VIUR_LOGGING_COLOR_CRITICAL set critical error level color The colors can be "black", "red", "green", "yellow", "blue", "magenta", "cyan" and "white". Example configuration using viur-cli ```sh VIUR_LOGGING_COLOR_WARNING=red VIUR_LOGGING_COLORIZATION=decent pipenv run viur run develop ``` For details on console coloring, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors. Initialize the formatter with specified format strings. Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format. Use a style parameter of '%', '{' or '$' to specify that you want to use one of %-formatting, :meth:`str.format` (``{}``) formatting or :class:`string.Template` formatting in your format string. .. versionchanged:: 3.2 Added the ``style`` parameter. .. py:attribute:: COLORS .. py:attribute:: DEFAULTS .. py:method:: colorize(level, text) :staticmethod: Retrieving colors for given debug level, either from environment or by default. .. py:method:: format(record) 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. .. py:data:: client .. py:data:: requestLogger .. py:data:: requestLoggingRessource .. py:data:: logger .. py:data:: EXCLUDED_LOGGER_DEFAULTS .. py:data:: excluded_logger .. py:data:: handler