Buffered SMTP Logging Handler
A library that mimics the standard logging.handlers.SMTPHandler class but sends email messages only when a preconfigured buffer is full or on exit.
Installation and dependencies
Install the program using pip:
pip install buffered_smtp_handler
How to use it
This library offers two classes: BufferedSMTPHandler and BufferedSMTPHandlerSSL.
They accept the same arguments of the standard SMTPHandler class, and also the capacity argument to set the capacity of the buffer (default: 100).
The SSL version is based on the smtplib.SMTP_SSL and avoids to perform StartSSL.
Via code:
>>> import logging
>>> from pierky.buffered_smtp_handler import BufferedSMTPHandler
>>> logger = logging.getLogger("my_app")
>>> logger.setLevel(logging.INFO)
>>> h = BufferedSMTPHandler("smtp.example.com", "from@example.com", ["to@example.com"], "MyApp log", capacity=10)
>>> logger.addHandler(h)
>>> logger.warning("Test")
Via a logging configuration file:
[loggers]
keys=root
[formatters]
keys=simple
[handlers]
keys=stderr,smtp
[logger_root]
level=INFO
handlers=stderr,smtp
[formatter_simple]
format=ARouteServer %(asctime)s %(levelname)s %(message)s
[handler_stderr]
class=StreamHandler
formatter=simple
args=(sys.stderr,)
[handler_smtp]
class=pierky.buffered_smtp_handler.BufferedSMTPHandler
level=WARN
formatter=simple
args=(('smtp.example.com', 25), 'from@example.com', ['to@example.com'], 'MyApp log')
Change log
v0.1.0
First release.
Metadata
Release files for buffered-smtp-handler 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| buffered_smtp_handler-0.1.0.tar.gz | 18.9 kB | Without provenance | Details |
Release files / buffered_smtp_handler-0.1.0.tar.gz
| Download URL | buffered_smtp_handler-0.1.0.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3d1a80b0d65a445b4264559ccfdf67cfa271c36972332436995b733b60650cb
|
|
BLAKE2b-256 checksum How to use checksums |
541bbbfeb8f5c54f1810049e4146765fa7fb7cd4e46eaa5c5913b4e2733429d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for buffered-smtp-handler 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.