vdat.libvdat – Stuff that isn’t GUI

Logging

Deal with loggers

vdat.libvdat.loggers.setup_main_logger(conf, name='logger')[source]

Setup the main vdat logger.

Add to the logger called name a standard output and a file logger

Parameters:
conf : ConfigParser instance

configuration options,

vdat.libvdat.loggers.make_logger(logger, conf, section=None)[source]

Create a handler using the instructions in the configuration section and add it to the logger.

It looks for the following options:

  • remove_old: if True remove all the previous handlers before adding the new one, default False
  • remove_std: if True remove all the previous StreamHandler`, default False
  • the ones used by make_handler()
Parameters:
logger : Logger instance

logger

conf : ConfigParser instance

configuration options

section : string, default

name of the section containing the information to build the logger; defaults to logging.name, where name is the logger name

vdat.libvdat.loggers.astropy_handlers(conf)[source]

Tweak the astropy logger removing the existing (stream) handlers and setting a new one if required

Parameters:
conf : ConfigParser instance

configuration options,

vdat.libvdat.loggers.ginga_handlers(conf)[source]

Create/update the ginga logger removing existing handlers setting a new one if required

Parameters:
conf : ConfigParser instance

configuration options,

vdat.libvdat.loggers.setup_command_loggers(main_config)[source]

Set up the loggers for the commands connected or connectible to buttons

Parameters:
main_config : ConfigParser instance

configuration options,

vdat.libvdat.loggers.add_parent(conf, section, from_parent=['logdir', 'logger_level'])[source]

Extract the section and, if from_parent is not an empty list, extend the section with those entry from the parent, without overwriting existing entries in section

The parent section of e.g. section=logging.main.stdout is logging.

Parameters:
conf : ConfigParser instance

configuration options,

section : string

name of the section in the configuration where to find all the info

Returns:
:class:`~pyhetdex.tools.configuration.ConfigParser` section
vdat.libvdat.loggers.make_handler(conf)[source]

Create a handler following the instructions contained in section

It looks for the following options:

  • enabled: if False, doesn’t create a handler and returns None; default False
  • file_name: if not found, a StreamHandler is created, if exists, a FileHandler is created
  • logdir: directory where the log file goes; default ‘.’
  • format: formatting of the message, default %(levelname)s: %(message)s
  • level: level of the handler, default INFO
Parameters:
conf : ConfigParser section

configuration options for the handler; it can be created using add_parent()

Returns:
None, if enabled is ``False``
:class:`~logging.StreamHandler`: if not file name is given
:class:`~logging.FileHandler`: otherwise
vdat.libvdat.loggers._to_log_level(level, default=20)[source]

Try to convert level to int or to extract the level level from the logging module. If both fail, return the default.

See here for more info about logging levels.

Parameters:
level : string

numerical or literal value of the level

Returns:
int

handler level