misc
default_record_fmt(record, asctime, after_time, after_msg)
¶
Format a log record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
record |
LogRecord
|
A log record. |
required |
asctime |
str
|
The string representing the time of creation. |
required |
after_time |
str
|
A string that will be placed after the time. |
required |
after_msg |
str
|
A string to be placed after the main message. |
required |
Returns:
Type | Description |
---|---|
str
|
A formatted string. |
Source code in m/log/misc.py
format_context(record, indent, show_traceback)
¶
Extract the context from a log record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
record |
LogRecord
|
The log record instance. |
required |
indent |
int
|
The level of indentation to apply to the string. |
required |
show_traceback |
bool
|
Attempts to display the traceback if it exists. |
required |
Returns:
Type | Description |
---|---|
str
|
A string with leading new line of the context associated with a log |
str
|
record. |
Source code in m/log/misc.py
format_location(parts, default_color='aqua')
¶
Join a list of possible defined strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parts |
list[str | None]
|
A list of possibly defined strings. |
required |
default_color |
str
|
The color to use for the string. |
'aqua'
|
Returns:
Type | Description |
---|---|
str
|
A string with the location or an empty string. |
Source code in m/log/misc.py
indent_payload(indent, payload, prepend_new_line=True, as_yaml=True)
¶
Stringify a dictionary as JSON and indent it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indent |
int
|
The number of spaces to indent. |
required |
payload |
dict
|
The data to stringify and indent. |
required |
prepend_new_line |
bool
|
Prepend a new line to the payload if |
True
|
as_yaml |
bool
|
Dump the payload in yaml. |
True
|
Returns:
Type | Description |
---|---|
str
|
An indented payload. |