alogging.formatters.django_sql_color module¶
-
class
alogging.formatters.django_sql_color.
DjangoDbSqlColorFormatter
(fmt=None, datefmt=None, style='%', options=None, pygments_lexer='postgres-console', pygments_formatter='terminal256', pygments_style='default')[source]¶ Bases:
logging.Formatter
Pretty print django.db sql with color by pyments
Parameters: - fmt – (str): The logging.Formatter format string
- datefmt (str) – The logging.Formatter date format string
- style (str) – The logging.Formatter format string type
- options (dict) – Dict of options to pass to sqlparse.format()
- pygments_lexer (str) – The name of the pygments lexer to use. Examples include: ‘postgres-console’, ‘postgres’, ‘rql’, ‘sql’, ‘sqlite3’, ‘mysql’, ‘plpgsql’, ‘tsql’
- pygments_formatter (str) – The name of the pygments formatter to use. Examples include: ‘terminal256’, ‘terminal’, ‘terminal16m’, ‘text’
- pygments_style (str) – The name of the pygments formatter style to use.
-
format
(record)[source]¶ Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.