Decorate all the logger methods so all the keys in the extra dictionary are automatically prefixed with an underscore to avoid clashes with standard log record attributes.
(logger)
| 169 | |
| 170 | |
| 171 | def decorate_logger_methods(logger): |
| 172 | """ |
| 173 | Decorate all the logger methods so all the keys in the extra dictionary are |
| 174 | automatically prefixed with an underscore to avoid clashes with standard log |
| 175 | record attributes. |
| 176 | """ |
| 177 | |
| 178 | # Note: We override findCaller with our custom implementation which takes into account this |
| 179 | # module. |
| 180 | # This way filename, module, funcName and lineno LogRecord attributes contain correct values |
| 181 | # instead of all pointing to decorate_log_method. |
| 182 | logger.findCaller = find_caller |
| 183 | for key in LOGGER_KEYS: |
| 184 | log_method = getattr(logger, key) |
| 185 | log_method = decorate_log_method(log_method) |
| 186 | setattr(logger, key, log_method) |
| 187 | |
| 188 | return logger |
| 189 | |
| 190 | |
| 191 | def getLogger(name): |
no test coverage detected