xpybuild.utils.consoleformatter

Pluggable classes for customizing the format that xpybuild uses when writing log messages to stdout (for example, for Teamcity, make, Visual Studio, etc).

ConsoleFormatter

class xpybuild.utils.consoleformatter.ConsoleFormatter(output, buildOptions, **kwargs)[source]

Bases: object

Base class for customizing the format used for handling log records when displaying to the command console/stdout.

This allows to output to be customized for the tool that is executing xpybuild, for example e.g. teamcity, visual studio IDE, etc.

Use self.fmt.format(record) to format the message including (multi-line) python exception traces.

This class is only used for stdout, it does not affect the format used to write messages to the on-disk xpybuild log file.

Parameters
  • output – The output stream, which can cope with unicode characters.

  • buildOptions – Dictionary of build options

publishArtifact(logger, displayName, path)[source]

Publishes the specified local path (e.g. a log file) as an artifact, if supported by this formatter.

The default implementation used by most formatters is a no-op.

Parameters
  • logger – The logger instance that should be used to write any messages to stdout as part of the publishing process (this will not be relevant for all formatters).

  • displayName – A string describing the artifact being published. Some output formatters may ignore this string.

  • path – An absolute path to a file (e.g. a log file) that should be published. Never equal to empty or None.

DefaultConsoleFormatter

class xpybuild.utils.consoleformatter.DefaultConsoleFormatter(stream, buildOptions, **kwargs)[source]

Bases: xpybuild.utils.consoleformatter.ConsoleFormatter

The default text output formatter for xpybuild.

TeamcityHandler

class xpybuild.utils.consoleformatter.TeamcityHandler(output, buildOptions, **kwargs)[source]

Bases: xpybuild.utils.consoleformatter.ConsoleFormatter

ConsoleFormatter that writes progress and error messages in a format suitable for Teamcity CI, and can publish artifacts such as build logs to Teamcity.

MakeConsoleFormatter

class xpybuild.utils.consoleformatter.MakeConsoleFormatter(output, buildOptions, **kwargs)[source]

Bases: xpybuild.utils.consoleformatter.ConsoleFormatter

ConsoleFormatter that logs in a format that matches GNU Make.

Output format:

file:line: category: description
Parameters
  • output – The output stream, which can cope with unicode characters.

  • buildOptions – Dictionary of build options

VisualStudioConsoleFormatter

class xpybuild.utils.consoleformatter.VisualStudioConsoleFormatter(output, **kwargs)[source]

Bases: xpybuild.utils.consoleformatter.ConsoleFormatter

ConsoleFormatter than writes warnings, errors and file locations in a format that Visual Studio can parse.

Required Format:

<location>: <category> <number>: <description>
where:
  • category = warning or error

  • number = specific error or warning number

  • location = <string> or <path>(line) or <path>(line-line) or <path>(line,col) or <path>(line,col-col)

  • description = free-form string

registerConsoleFormatter

xpybuild.utils.consoleformatter.registerConsoleFormatter(name: str, handler: xpybuild.utils.consoleformatter.ConsoleFormatter)[source]

Make a custom console formatter class available for use by xpybuild.

publishArtifact

xpybuild.utils.consoleformatter.publishArtifact(displayName, path)[source]

Publishes the specified local path as an artifact, if supported by the configured output format.

For example this can be used to publish log and error output if a target fails.

Note that many output formatters do not have any concept of artifact publishing, so it is usually desirable to log important paths at INFO or WARN/ERROR or above in addition to calling this method.

Parameters
  • displayName – A string describing the artifact being published. Some output formatters may ignore this string.

  • path – An absolute path to a file (e.g. a log file) that should be published, if supported. Empty string or None are ignored.