coalib.output.printers package

Submodules

coalib.output.printers.EspeakPrinter module

class coalib.output.printers.EspeakPrinter.EspeakPrinter

Bases: pyprint.Printer.Printer, pyprint.ClosableObject.ClosableObject

coalib.output.printers.HTMLWriter module

class coalib.output.printers.HTMLWriter.HTMLWriter(filename, indentation_per_tag=2, indentation=0)

Bases: pyprint.ClosableObject.ClosableObject

Printer for outputting HTML Log files.

Parameters:
  • filename – the name of the file to put the data into (string).
  • indentation_per_tag – spaces used to indent every subsequent HTML tag.
Raises:

TypeError – if directory of given file doesn’t exist or in case of access problems.

close_tag(tag_name)

Function to close an open HTML tag. e.g. </p>

Parameters:tag_name – the name of HTML Tag to be written to output logfile.
open_tag(tag_name)

Function to open HTML tag. e.g. <p>

Parameters:tag_name – the name of HTML Tag to written in the output logfile.
write(*args)

Function to write in the given output HTML log file.

Parameters:args – arbitrary number of arguments to be written to output logfile.
write_comment(*comments)

Function for writing HTML comments in the output HTML log files.

Parameters:comments – an arbitrary number of comments to add to the HTML log file
write_tag(tag, content='', **tagargs)

Function for writing an HTML tag, along with the required tag attributes and content.

Parameters:
  • tag – HTML Tag for formatting the content.
  • content – content to output into the HTML Log file.
  • tagargs – arbitrary HTML tag attributes mapped to their respective values. Ordering of the tags is not preserved.

coalib.output.printers.LOG_LEVEL module

coalib.output.printers.ListLogPrinter module

class coalib.output.printers.ListLogPrinter.ListLogPrinter(log_level=2, timestamp_format='%X')

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

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)

coalib.output.printers.LogPrinter module

class coalib.output.printers.LogPrinter.LogPrinter(printer, log_level=1, timestamp_format='%X')

Bases: object

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.

debug(*messages, delimiter=' ', timestamp=None, **kwargs)
err(*messages, delimiter=' ', timestamp=None, **kwargs)
info(*messages, delimiter=' ', timestamp=None, **kwargs)
log(log_level, message, timestamp=None, **kwargs)
log_exception(message, exception, log_level=3, timestamp=None, **kwargs)

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 occured. 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)
printer

Returns the underlying printer where logs are printed to.

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

coalib.output.printers.StringPrinter module

class coalib.output.printers.StringPrinter.StringPrinter

Bases: pyprint.Printer.Printer

This is a simple printer that prints everything to a string.

clear()

Clears the print string.

string

Gets the print string.

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.