| 131 | self.logger.debug(self._template(caller_info, msg)) |
| 132 | |
| 133 | def critical(self, exc: Optional[Exception] = None, msg: Optional[str] = ""): |
| 134 | frame = getframeinfo(currentframe().f_back) |
| 135 | caller_info = { |
| 136 | "module": getmodulename(frame.filename), |
| 137 | "filename": frame.filename, |
| 138 | "line": frame.lineno, |
| 139 | "function": frame.function, |
| 140 | } |
| 141 | excStr = "" |
| 142 | if exc is not None: |
| 143 | if isinstance(exc, BaseException): |
| 144 | excStr = "".join(format_exception(type(exc), exc, exc.__traceback__)) |
| 145 | else: |
| 146 | excStr = str(exc) |
| 147 | self.logger.critical(self._template(caller_info, f"{msg}\n{excStr}")) |
| 148 | |
| 149 | |
| 150 | # Example usage |