Logging - vcspull.log#

Log utilities for formatting CLI output in vcspull.

This module containers special formatters for processing the additional context information from libvcs.base.RepoLoggingAdapter.

Colorized formatters for generic logging inside the application is also provided.

vcspull.log.setup_logger(log=None, level='INFO')[source]#

Configure vcspull logger for CLI use.

Return type:

None

Parameters:
  • log (logging.Logger) – instance of logger

  • level (Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']) –

class vcspull.log.LogFormatter(color=True, **kwargs)[source]#

Bases: Formatter

Log formatting for vcspull.

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.

Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting, str.format() ({}) formatting or string.Template formatting in your format string.

Changed in version 3.2: Added the style parameter.

Parameters:
  • color (bool) –

  • kwargs (Any) –

template(record)[source]#

Return the prefix for the log message. Template for Formatter.

Return type:

str

Parameters:

record (logging.LogRecord) – Passed in from inside the logging.Formatter.format() record.

format(record)[source]#

Format log record.

Return type:

str

Parameters:

record (LogRecord) –

class vcspull.log.DebugLogFormatter(color=True, **kwargs)[source]#

Bases: LogFormatter

Provides greater technical details than standard log Formatter.

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.

Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting, str.format() ({}) formatting or string.Template formatting in your format string.

Changed in version 3.2: Added the style parameter.

Parameters:
  • color (bool) –

  • kwargs (Any) –

template(record)[source]#

Return the prefix for the log message. Template for Formatter.

Return type:

str

Parameters:

record (logging.LogRecord) – Passed from inside the logging.Formatter.format() record.

class vcspull.log.RepoLogFormatter(color=True, **kwargs)[source]#

Bases: LogFormatter

Log message from vcs repository.

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.

Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting, str.format() ({}) formatting or string.Template formatting in your format string.

Changed in version 3.2: Added the style parameter.

Parameters:
  • color (bool) –

  • kwargs (Any) –

template(record)[source]#

Template for logging vcs bin name, along with a contextual hint.

Return type:

str

Parameters:

record (LogRecord) –

class vcspull.log.RepoFilter(name='')[source]#

Bases: Filter

Only include repo logs for this type of record.

Initialize a filter.

Initialize with the name of the logger which, together with its children, will have its events allowed through the filter. If no name is specified, allow every event.

filter(record)[source]#

Only return a record if a keyword object.

Return type:

bool

Parameters:

record (LogRecord) –