dhcpkit.common.server.logging.config_elements module

The basic configuration objects for logging

class dhcpkit.common.server.logging.config_elements.ConsoleHandlerFactory(section: ZConfig.matcher.SectionValue)[source]

Bases: dhcpkit.common.server.config_elements.ConfigElementFactory

Factory for a logging handler that logs to the console, optionally in colour.

create() → logging.StreamHandler[source]

Create a console handler

Returns:The logging handler
validate_config_section()[source]

Validate the colorlog setting

class dhcpkit.common.server.logging.config_elements.FileHandlerFactory(section: ZConfig.matcher.SectionValue)[source]

Bases: dhcpkit.common.server.config_elements.ConfigElementFactory

Factory for a logging handler that logs to a file, optionally rotating it.

create() → logging.StreamHandler[source]

Create a console handler

Returns:The logging handler
static name_datatype(v)
validate_config_section()[source]

Validate if the combination of settings is valid

class dhcpkit.common.server.logging.config_elements.Logging(section: ZConfig.matcher.SectionValue)[source]

Bases: dhcpkit.common.server.config_elements.ConfigSection

Class managing the configured logging handlers.

configure(logger: logging.Logger, verbosity: int = 0) → int[source]

Add all configured handlers to the supplied logger. If verbosity > 0 then make sure we have a console logger and force the level of the console logger based on the verbosity.

Parameters:
  • logger – The logger to add the handlers to
  • verbosity – The verbosity level given as command line argument
Returns:

The lowest log level that is going to be handled

validate_config_section()[source]

Check for duplicate handlers

class dhcpkit.common.server.logging.config_elements.SysLogHandlerFactory(section: ZConfig.matcher.SectionValue)[source]

Bases: dhcpkit.common.server.config_elements.ConfigElementFactory

Factory for a logging handler that logs to syslog.

clean_config_section()[source]

Fill in the name automatically if not given

create() → logging.handlers.SysLogHandler[source]

Create a syslog handler

Returns:The logging handler
default_destinations = ('/dev/log', '/var/run/syslog', 'localhost:514')
static name_datatype(value)