bittensor.utils.btlogging.format#
btlogging.format module
This module defines custom logging formatters for the Bittensor project.
Attributes#
Classes#
BtFileFormatter |
|
A custom logging formatter for the Bittensor project that overrides the time formatting to include milliseconds, |
Functions#
Module Contents#
- class bittensor.utils.btlogging.format.BtFileFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]#
Bases:
logging.Formatter
BtFileFormatter
A custom logging formatter for the Bittensor project that overrides the time formatting to include milliseconds and centers the level name.
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 orstring.Template
formatting in your format string.Changed in version 3.2: Added the
style
parameter.- format(record)[source]#
Override format to center the level name.
- Parameters:
record (logging.LogRecord) – The log record.
- Returns:
The formatted log record.
- Return type:
formatted record (str)
- formatTime(record, datefmt=None)[source]#
Override formatTime to add milliseconds.
- Parameters:
record (logging.LogRecord) – The log record.
datefmt (Optional[str]) – The date format string.
- Returns:
The formatted time string with milliseconds.
- Return type:
s (str)
- class bittensor.utils.btlogging.format.BtStreamFormatter(*args, **kwargs)[source]#
Bases:
logging.Formatter
A custom logging formatter for the Bittensor project that overrides the time formatting to include milliseconds, centers the level name, and applies custom log formats, emojis, and colors.
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 orstring.Template
formatting in your format string.Changed in version 3.2: Added the
style
parameter.- format(record)[source]#
Override format to apply custom formatting including emojis and colors.
This method saves the original format, applies custom formatting based on the log level and trace flag, replaces text with emojis and colors, and then returns the formatted log record.
- Parameters:
record (logging.LogRecord) – The log record.
- Returns:
The formatted log record.
- Return type:
result (str)
- formatTime(record, datefmt=None)[source]#
Override formatTime to add milliseconds.
- Parameters:
record (logging.LogRecord) – The log record.
datefmt (Optional[str]) – The date format string.
- Returns:
The formatted time string with milliseconds.
- Return type:
s (str)
- trace = False#
- bittensor.utils.btlogging.format._success(self, message, *args, **kws)[source]#
- Parameters:
message (str)