_handlers
Use these classes to instantiate logging handlers for a logging dictConfig.
Each class has a .get_configdict() method, which returns a dict representation of the class
that can be added to a logging config dict.
BaseHandlerConfig
dataclass
Bases: BaseLoggingConfig
Abstract base class for a logging handler dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
The handler's name. |
None
|
level |
str
|
The handler's logging level (NOTSET, DEBUG, INFO, WARNING, ERROR, CRITICAL). |
'NOTSET'
|
formatter |
str
|
The name of a formatter that exists in the logging config. |
None
|
filters |
list[str] | None
|
The names of logging filter methods/classes. These methods/classes
must be imported into the script where |
None
|
Source code in src/red_logging/config_classes/base/_bases.py
get_configdict()
abstractmethod
Return a dict representation of the handler config.
Source code in src/red_logging/config_classes/base/_bases.py
BaseLoggingConfig
dataclass
FileHandlerConfig
dataclass
Bases: BaseHandlerConfig
Define a logging FileHandler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename |
str
|
The name of the file to log messages to. |
'app.log'
|
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_configdict()
Return a dict representation of the handler described by this class.
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_handler_class()
Return the logging handler class this class represents.
Returns:
| Type | Description |
|---|---|
str
|
|
QueueHandlerConfig
dataclass
Bases: BaseHandlerConfig
Define a logging QueueHandler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queue |
Queue
|
The queue to send log messages to. |
None
|
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_configdict()
Return a dict representation of the handler described by this class.
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_handler_class()
Return the logging handler class this class represents.
Returns:
| Type | Description |
|---|---|
str
|
|
QueueListenerConfig
dataclass
Bases: BaseLoggingConfig
Define a logging QueueListener.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
The name of the handler. |
required |
queue |
Queue
|
The queue to listen for log messages in. |
required |
handlers |
list[str]
|
List of handler names to apply to this listener. |
required |
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_configdict()
Return a dict representation of the handler described by this class.
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_handler_class()
Return the logging handler class this class represents.
Returns:
| Type | Description |
|---|---|
str
|
|
RotatingFileHandlerConfig
dataclass
Bases: BaseHandlerConfig
Define a logging RotatingFileHandler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename |
str | None
|
The name/path of the file to log messages to. |
'app.log'
|
maxBytes |
int
|
The maximum size of the file (in bytes) before a new file is rotated. |
0
|
backupCount |
int
|
Number of rotated log files to keep. |
0
|
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_configdict()
Return a dict representation of the handler described by this class.
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_handler_class()
Return the logging handler class this class represents.
Returns:
| Type | Description |
|---|---|
str
|
|
SMTPHandlerConfig
dataclass
Bases: BaseHandlerConfig
Define a logging SMTPHandler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mailhost |
Any
|
... |
None
|
fromaddr |
str
|
... |
'from@example.com'
|
toaddrs |
list
|
... |
lambda: []()
|
subject |
str
|
... |
'SMTPHandler Log Event'
|
credentials |
tuple
|
... |
None
|
secure |
tuple
|
... |
None
|
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_configdict()
Return a dict representation of the handler described by this class.
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_handler_class()
Return the logging handler class this class represents.
Returns:
| Type | Description |
|---|---|
str
|
|
SocketHandlerConfig
dataclass
Bases: BaseHandlerConfig
Define a logging SocketHandler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host |
str
|
Host IP/FQDN. |
'localhost'
|
port |
int
|
Host port where log messages should be sent. |
0
|
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_configdict()
Return a dict representation of the handler described by this class.
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_handler_class()
Return the logging handler class this class represents.
Returns:
| Type | Description |
|---|---|
str
|
|
StreamHandlerConfig
dataclass
Bases: BaseHandlerConfig
Define a logging StreamHandler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream |
Any
|
The stream this handler controls, i.e. |
'ext://sys.stdout'
|
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_configdict()
Return a dict representation of the handler described by this class.
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_handler_class()
Return the logging handler class this class represents.
Returns:
| Type | Description |
|---|---|
str
|
|
TimedRotatingFileHandlerConfig
dataclass
Bases: BaseHandlerConfig
Define a logging TimedRotatingFileHandler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename |
str
|
The name/path of the file to log messages to. |
'app.log'
|
when |
str
|
Time of day to rotate log files, i.e. |
'midnight'
|
interval |
int
|
When to rotate the file as the interval defined in |
1
|
backupCount |
int
|
The number of rotated log files to save. |
0
|
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_configdict()
Return a dict representation of the handler described by this class.
Source code in src/red_logging/config_classes/handlers/_handlers.py
get_handler_class()
Return the logging handler class this class represents.
Returns:
| Type | Description |
|---|---|
str
|
|