coalib.output.printers package

Submodules

coalib.output.printers.LOG_LEVEL module

coalib.output.printers.ListLogPrinter module

class coalib.output.printers.ListLogPrinter.ListLogPrinter(log_level=30, timestamp_format='%X')[source]

Bases: pyprint.Printer.Printer, coalib.output.printers.LogPrinter.LogPrinterMixin

A ListLogPrinter is a log printer which collects all LogMessages to a list so that the logs can be used at a later time.

log_message(log_message, **kwargs)[source]

coalib.output.printers.LogPrinter module

class coalib.output.printers.LogPrinter.LogPrinter(printer=None, log_level=10, timestamp_format='%X')[source]

Bases: coalib.output.printers.LogPrinter.LogPrinterMixin

This class is deprecated and will be soon removed. To get logger use logging.getLogger(__name__). Make sure that you’re getting it when the logging configuration is loaded.

The LogPrinter class allows to print log messages to an underlying Printer.

This class is an adapter, means you can create a LogPrinter from every existing Printer instance.

log_level

Returns current log_level used in logger.

log_message(log_message, **kwargs)[source]
printer

Returns the underlying printer where logs are printed to.

class coalib.output.printers.LogPrinter.LogPrinterMixin[source]

Bases: object

Provides access to the logging interfaces (e.g. err, warn, info) by routing them to the log_message method, which should be implemented by descendants of this class.

debug(*messages, delimiter=' ', timestamp=None, **kwargs)[source]
err(*messages, delimiter=' ', timestamp=None, **kwargs)[source]
info(*messages, delimiter=' ', timestamp=None, **kwargs)[source]
log(log_level, message, timestamp=None, **kwargs)[source]
log_exception(message, exception, log_level=40, timestamp=None, **kwargs)[source]

If the log_level of the printer is greater than DEBUG, it prints only the message. If it is DEBUG or lower, it shows the message along with the traceback of the exception.

Parameters:
  • message – The message to print.
  • exception – The exception to print.
  • log_level – The log_level of this message (not used when logging the traceback. Tracebacks always have a level of DEBUG).
  • timestamp – The time at which this log occurred. Defaults to the current time.
  • kwargs – Keyword arguments to be passed when logging the message (not used when logging the traceback).
log_message(log_message, **kwargs)[source]

It is your reponsibility to implement this method, if you’re using this mixin.

warn(*messages, delimiter=' ', timestamp=None, **kwargs)[source]

Module contents

This package holds printer objects. Printer objects are general purpose and not tied to coala.

If you need logging capabilities please take a look at the LogPrinter object which adds logging capabilities “for free” if used as base class for any other printer.