pythonjsonlogger.defaults
🔗
Collection of functions for building custom json_default
functions.
In general functions come in pairs of use_x_default
and x_default
, where the former is used
to determine if you should call the latter.
Most use_x_default
functions also act as a TypeGuard
.
bytes_default
🔗
dataclass_default
🔗
Default function for dataclass instances
PARAMETER | DESCRIPTION |
---|---|
obj |
object to handle
|
date_default
🔗
Default function for datetime.date
instances
PARAMETER | DESCRIPTION |
---|---|
obj |
object to handle
TYPE:
|
datetime_any
🔗
datetime_default
🔗
Default function for datetime.datetime
instances
PARAMETER | DESCRIPTION |
---|---|
obj |
object to handle
TYPE:
|
enum_default
🔗
Default function for enums.
Supports both enum classes and enum values.
PARAMETER | DESCRIPTION |
---|---|
obj |
object to handle
TYPE:
|
exception_default
🔗
exception_default(obj: BaseException) -> str
Default function for exception instances
PARAMETER | DESCRIPTION |
---|---|
obj |
object to handle
TYPE:
|
time_default
🔗
Default function for datetime.time
instances
PARAMETER | DESCRIPTION |
---|---|
obj |
object to handle
TYPE:
|
traceback_default
🔗
traceback_default(obj: TracebackType) -> str
Default function for tracebacks
PARAMETER | DESCRIPTION |
---|---|
obj |
object to handle
TYPE:
|
type_default
🔗
Default function for type
objects.
PARAMETER | DESCRIPTION |
---|---|
obj |
object to handle
TYPE:
|
unknown_default
🔗
Backup default function for any object type.
Will attempt to use str
or repr
. If both functions error will return
the string "__could_not_encode__"
.
PARAMETER | DESCRIPTION |
---|---|
obj |
object to handle
TYPE:
|
use_bytes_default
🔗
Default check function for bytes
use_dataclass_default
🔗
Default check function for dataclass instances
use_date_default
🔗
Default check function for datetime.date
instances
use_datetime_any
🔗
Default check function for datetime
related instances
use_datetime_default
🔗
Default check function for datetime.datetime
instances
use_enum_default
🔗
Default check function for enums.
Supports both enum classes and enum values.
use_exception_default
🔗
use_exception_default(obj: Any) -> TypeGuard[BaseException]
Default check function for exception instances.
Exception classes are not treated specially and should be handled by the
[use_]type_default
functions.
use_time_default
🔗
Default check function for datetime.time
instances
use_traceback_default
🔗
use_traceback_default(obj: Any) -> TypeGuard[TracebackType]
Default check function for tracebacks
use_type_default
🔗
Default check function for type
objects (aka classes).
use_uuid_default
🔗
Default check function for uuid.UUID
instances