pyyaks.logger

Customize logging to add a VERBOSE level and provide a logger for which the trailing newline can be suppressed.

Functions

pyyaks.logger.get_logger(filename=None, filemode='w', format='%(message)s', datefmt=None, level=20, stream=<open file '<stdout>', mode 'w' at 0x7f20ff9c31e0>, filelevel=None, name='pyyaks')

Do basic configuration for the logging system. Similar to logging.basicConfig but the logger name is configurable and both a file output and a stream output can be created.

Returns a logger object. For this logger the trailing newline in invidual handlers can be suppressed by setting the suppress_newline attribute to True for that handler. More normally use the newlines_suppressed context manager.

The default behaviour is to create a StreamHandler which writes to sys.stdout, set a formatter using the “%(message)s” format string, and add the handler to the “pyyaks” logger.

A number of optional keyword arguments may be specified, which can alter the default behaviour.

Parameters:
  • filename – create FileHandler using the specified filename
  • filemode – open filename with specified filemode
  • format – handler format string
  • datefmt – handler date/time format specifier
  • level – logger level (default=INFO).
  • filelevel – logger level for the file logger. defaults to level if not specified.
  • stream – initialize the StreamHandler using stream Defaults to sys.stdout. Set to None to disable.
  • name – Logger name
pyyaks.logger.newlines_suppressed(*args, **kwds)

Context manager to suppress newline output for each handler in the supplied logger. Example:

with newlines_suppressed(logger):
    logger.info('Starting something ... ')
# process ...
logger.info('done')
Parameters:logger – logger object created with get_logger()

Table Of Contents

Previous topic

pyyaks.fileutil

Next topic

pyyaks.shell

This Page