textmate_grammar.utils.logger
¶
Module Contents¶
Classes¶
A custom log formatter that formats log records with color-coded messages. |
|
The logger object for the grammar parsers. |
Functions¶
Simple decorator to track recusion depth. |
Data¶
API¶
- textmate_grammar.utils.logger.MAX_LENGTH = 79¶
- class textmate_grammar.utils.logger.LogFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]¶
Bases:
logging.Formatter
A custom log formatter that formats log records with color-coded messages.
Initialization
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.- green = '\x1b[32;32m'¶
- grey = '\x1b[38;20m'¶
- yellow = '\x1b[33;20m'¶
- red = '\x1b[31;20m'¶
- bold_red = '\x1b[31;1m'¶
- reset = '\x1b[0m'¶
- format_string = '%(name)s:%(message)s'¶
- FORMATS = None¶
- class textmate_grammar.utils.logger.Logger(**kwargs)[source]¶
The logger object for the grammar parsers.
Initialization
- long_msg_div = '\x1b[1;32m ... \x1b[0m'¶
- configure(parser: textmate_grammar.parser.GrammarParser, height: int, width: int, **kwargs) None [source]¶
Configures the logger to a specific grammar and content length
- format_message(message: str, parser: textmate_grammar.parser.GrammarParser | None = None, position: tuple[int, int] | None = None, depth: int = 0) str [source]¶
Formats a logging message to the defined format.
- Parameters:
message – The logging message to be formatted.
parser – The GrammarParser object associated with the message. Defaults to None.
position – The position tuple (line, column) associated with the message. Defaults to None.
depth – The depth of the message in the logging hierarchy. Defaults to 0.
- Returns:
The formatted logging message.
- textmate_grammar.utils.logger.LOGGER = 'Logger(...)'¶