logger
Logger
¶
Wrapper for python Logger to enable inserting logs in fp loops.
This is also so that we may attach context data for a message.
We can access the actual logger by using inst
.
Source code in m/log/logger.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
__init__(name)
¶
Initialize the Logger.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of a logger. |
required |
Source code in m/log/logger.py
close_block(name, stderr=False)
¶
Close a group log lines.
Signals the formatter that the current group of lines should end.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the block to close. |
required |
stderr |
bool
|
Force message to be displayed in stderr. |
False
|
Returns:
Type | Description |
---|---|
Res[int]
|
A OneOf containing 0 to make it easier to call in fp for loops. |
Source code in m/log/logger.py
error_block(msg, context)
¶
Display an error block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str | Message
|
The error message to display. |
required |
context |
dict | Issue
|
The dict/Issue to display in a block. |
required |
Returns:
Type | Description |
---|---|
Res[int]
|
A OneOf containing 0 to make it easier to call in fp for loops. |
Source code in m/log/logger.py
open_block(name, description, stderr=False)
¶
Group log lines.
Signals the formatter that the next log lines should be placed in a group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the block to open. |
required |
description |
str
|
Not supported. |
required |
stderr |
bool
|
Force message to be displayed in stderr. |
False
|
Returns:
Type | Description |
---|---|
Res[int]
|
A OneOf containing 0 to make it easier to call in fp for loops. |
Source code in m/log/logger.py
waning_block(msg, context)
¶
Display a warning block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str | Message
|
The warning message to display. |
required |
context |
dict | Issue
|
The dict/Issue to display in a block. |
required |
Returns:
Type | Description |
---|---|
Res[int]
|
A OneOf containing 0 to make it easier to call in fp for loops. |
Source code in m/log/logger.py
PromptLogger
¶
Bases: Logger
Adding a prompt level to the logger.
Source code in m/log/logger.py
__init__(name, level=logging.NOTSET)
¶
prompt(msg, *args, **kwargs)
¶
Log 'msg % args' with severity 'PROMPT'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
The message to log |
required |
args |
Any
|
arguments to use in the message replacement. |
()
|
kwargs |
Any
|
The keywords arguments to provide extra information. |
{}
|
Source code in m/log/logger.py
log_func_wrapper(func, msg, context=None, exit_code=0)
¶
Call a logger function with a message and log data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable
|
A logger function (logger.info) |
required |
msg |
str | Message
|
A string or Message containing information about the log. |
required |
context |
dict | Issue | None
|
Data describing the log entry. |
None
|
exit_code |
int
|
Used in cli context to force an exit. Default to 0. |
0
|
Returns:
Type | Description |
---|---|
Res[int]
|
A OneOf containing 0 to make it easier to call in fp for loops. |
Res[int]
|
May be overwritten when signaling an error. |