(format_string="", *args, **kwargs)
| 178 | |
| 179 | |
| 180 | def _exception(format_string="", *args, **kwargs): |
| 181 | level = kwargs.pop("level", "error") |
| 182 | exc_info = kwargs.pop("exc_info", sys.exc_info()) |
| 183 | |
| 184 | if format_string: |
| 185 | format_string += "\n\n" |
| 186 | format_string += "{exception}\nStack where logged:\n{stack}" |
| 187 | |
| 188 | exception = "".join(traceback.format_exception(*exc_info)) |
| 189 | |
| 190 | f = inspect.currentframe() |
| 191 | f = f.f_back if f else f # don't log this frame |
| 192 | try: |
| 193 | stack = "".join(traceback.format_stack(f)) |
| 194 | finally: |
| 195 | del f # avoid cycles |
| 196 | |
| 197 | write_format( |
| 198 | level, format_string, *args, exception=exception, stack=stack, **kwargs |
| 199 | ) |
| 200 | |
| 201 | |
| 202 | def swallow_exception(format_string="", *args, **kwargs): |
no test coverage detected
searching dependent graphs…