bittensor.utils.btlogging.format#
btlogging.format module
This module defines custom logging formatters for the Bittensor project.
Attributes#
Classes#
| A custom logging formatter for the Bittensor project that overrides the time formatting to include milliseconds, | |
| BtFileFormatter | 
Functions#
Module Contents#
- bittensor.utils.btlogging.format._trace(self, message, *args, **kws)[source]#
- Parameters:
- message (str) 
 
- bittensor.utils.btlogging.format._success(self, message, *args, **kws)[source]#
- Parameters:
- message (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 or- string.Templateformatting in your format string.- Changed in version 3.2: Added the - styleparameter.- trace = False#
 - 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) 
 
 - 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) 
 
 
- 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 or- string.Templateformatting in your format string.- Changed in version 3.2: Added the - styleparameter.- 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) 
 
 - format(record)[source]#
- Override format to center the level name. - Parameters:
- record (logging.LogRecord) – The log record. 
- Returns:
- The formatted log record. 
- Return type:
- formated record (str)