record.log.logger module¶
A module for log utilities.
It provides consistent log level and format, and always write to logger_name.log file. The project should use this instead of standard logging module.
Differences with logging.getLogger:
Multiple level logger is not supported.
Exception backtracing stack is fixed.
According to https://stackoverflow.com/questions/47968861/does-python-logging-support-multiprocessing, logging within pipe_size, which is usually 4096 btyes, is atomic. It is big enough for most of the situation, except for backtracing. Have to restrict backtrace level.
- class record.log.logger.Logger(name, level=0)[源代码]¶
基类:
Logger
- findCaller(stack_info: bool = False, stacklevel: int = 1)[源代码]¶
Find the stack frame of the caller so that we can note the source file name, line number and function name.
- static format_request(request: HttpRequest) str [源代码]¶
- listener(message: str = '', *, as_view: bool = False, raise_exc: bool | None = None) Callable[[Exception, Callable, tuple[Any, ...], dict[str, Any]], None] [源代码]¶
- makeRecord(*args, **kwargs)[源代码]¶
A factory method which can be overridden in subclasses to create specialized LogRecords.
- on_exception(message: str = '', *, request: HttpRequest | None = None, raise_exc: bool | None = None) None [源代码]¶
Log exception and raise it if needed.
- 参数:
message (str, optional) -- 基础日志信息. Defaults to ''.
request (HttpRequest, optional) -- 记录请求信息. Defaults to None.
raise_exc (bool, optional) -- 是否抛出异常,不提供则根据debug模式决定
- secure_func(message: str = '', *, raise_exc: bool | None = False, fail_value: ~typing.Any | ~typing.Callable[[], ~typing.Any] = None, exc_type: type[Exception] | tuple[type[Exception], ...] = <class 'Exception'>) Callable[[Callable[[P], T]], Callable[[P], T]] [源代码]¶
- secure_view(message: str = '', *, raise_exc: bool | None = None, fail_value: ~typing.Any | ~typing.Callable[[], ~typing.Any] = None, exc_type: type[Exception] | tuple[type[Exception], ...] = <class 'Exception'>) Callable[[Callable[[Concatenate[R, P]], T]], Callable[[Concatenate[R, P]], T]] [源代码]¶