log_message
Log message using logger based on status_code and logger level.
Pass `request`, `status_code` (if defined) and any provided `extra` as such
to the logging method,
Arguments from `args` will be escaped to avoid potential log injections.
def log_message(
logger: logging.Logger,
message: string,
*args: any,
level: string = null,
status_code: integer = null,
request: HttpRequest = null,
exception: Exception = null,
**extra: any
) - > null
Log message using logger based on status_code and logger level. Pass request, status_code (if defined) and any provided extra as such to the logging method, Arguments from args will be escaped to avoid potential log injections.
Parameters
| Name | Type | Description |
|---|---|---|
| logger | logging.Logger | The logger instance used to emit the log record. |
| message | string | The log message format string. |
| *args | any | Positional arguments to be merged into the message; string values are escaped to prevent log injection. |
| level | string = null | The logging level name (e.g., 'info', 'error'); if omitted, it is inferred from the status_code or defaults to 'info'. |
| status_code | integer = null | The HTTP status code used to determine the default log level (500+ for error, 400+ for warning). |
| request | HttpRequest = null | The request object to be included in the log's extra context. |
| exception | Exception = null | An exception instance to be logged with traceback information via exc_info. |
| **extra | any | Additional keyword arguments to be included in the log record's extra dictionary. |
Returns
| Type | Description |
|---|---|
null | This function does not return a value. |