Args: depth (int): Depth of caller conext, use 0 for caller depth. Default value: 0. Returns: str: module name of the caller
(depth=0)
| 209 | |
| 210 | |
| 211 | def get_caller_name(depth=0): |
| 212 | """ |
| 213 | Args: |
| 214 | depth (int): Depth of caller conext, use 0 for caller depth. |
| 215 | Default value: 0. |
| 216 | |
| 217 | Returns: |
| 218 | str: module name of the caller |
| 219 | """ |
| 220 | # the following logic is a little bit faster than inspect.stack() logic |
| 221 | frame = inspect.currentframe().f_back |
| 222 | for _ in range(depth): |
| 223 | frame = frame.f_back |
| 224 | |
| 225 | return frame.f_globals["__name__"] |
| 226 | |
| 227 | |
| 228 | class StreamToLoguru: |