QgisLogger
Import
from pyqgis_wrapper.utils import QgisLogger, LoggerMixin, create_child_logger
LevelFilter(level=logging.INFO)
¶
Bases: logging.Filter
Provide a filter to log message higher than the filter level
Init the filter with a filter level
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int
|
Filter level, defaults to logging.INFO |
logging.INFO
|
Source code in pyqgis_wrapper/utils/log_handler.py
49 50 51 52 53 54 55 56 57 | |
LoggerMixin
¶
Mixin to use to st up a root logger in your plugin.
You can call set_up_logger with the root name of your plugin. All your logger in this plugin with have the settings (log level) from this logger
You can update the level of the filter level using set_level to propagate in childs logger for exmaple given the state of a checkbox.
set_up_logger(root_name='pyqgis_wrapper', feedback=None, level=logging.INFO)
¶
Setup root logger
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_name
|
str
|
Name of the root logger. Should be the root of your plugin, defaults to "pyqgis_wrapper" |
'pyqgis_wrapper'
|
feedback
|
typing.Optional[qgis.core.QgsProcessingFeedback]
|
Optionnal feedback object to provide to handler within QGIS, defaults to None |
None
|
level
|
int
|
Filter level to use, defaults to logging.INFO |
logging.INFO
|
Source code in pyqgis_wrapper/utils/log_handler.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
unset_logger()
¶
Should be called on plugin unload to reset to original logger
Source code in pyqgis_wrapper/utils/log_handler.py
100 101 102 103 104 | |
set_level(level=logging.INFO)
¶
Set the filter levle of the root logger and propagate to child.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int
|
Filter level, defaults to logging.INFO |
logging.INFO
|
Source code in pyqgis_wrapper/utils/log_handler.py
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 | |
QgisLogger(name='pyqgis_wrapper', feedback=None, level=logging.INFO)
¶
Bases: logging.Logger
QgisLogger Logger that accept either a stream handler or a QgsFeedback handler
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
(str, optional)
|
Name of the logger (global), defaults to "qgis" |
'pyqgis_wrapper'
|
feedback
|
typing.Optional[qgis.core.QgsProcessingFeedback]
|
Feedback object if executed within QGIS. Will be use to construct the handler, defaults to None |
None
|
debug_mode
|
(typing.Optional[bool], optional)
|
If True will output the entire stack trace, defaults to None The state is propagated from the root logger if None. |
required |
Source code in pyqgis_wrapper/utils/log_handler.py
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 | |
log_exception(exc, context='')
¶
Catch an error and call the method corresponding to severity
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc
|
Exception
|
Catched exception |
required |
context
|
str
|
Additionnal information to push |
''
|
Source code in pyqgis_wrapper/utils/log_handler.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
FeedbackLogHandler(feedback)
¶
Bases: logging.Handler
QgsProcessingFeedback handler for execution within QGIS
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feedback
|
qgis.core.QgsProcessingFeedback
|
Feedback object |
required |
Source code in pyqgis_wrapper/utils/log_handler.py
235 236 237 238 239 240 241 | |
create_child_logger(name)
¶
Set up a child logger with levle and debug mode of the direct parent
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the child |
required |
Returns:
| Type | Description |
|---|---|
QgisLogger
|
Child logger |
Source code in pyqgis_wrapper/utils/log_handler.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |