SysLogHandler with TLS
Project description
Python logging.handler as a drop-in replacement for logging.SysLogHandler with support for sending syslog messages over TCP with TLS.
Installation
pip install tlssysloghandler
Usage
import logging
from tlssysloghandler import TLSSysLogHandler
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# with default system certificate store
handler1 = TLSSysLogHandler(address=('secure-logging.example.com', 6514),
socktype=socket.SOCK_STREAM,
secure=True)
logger.addHandler(handler1)
# with custom certificates, via cafile/capath/cadata
# refer to https://docs.python.org/3/library/ssl.html#ssl.create_default_context
handler2 = TLSSysLogHandler(address=('secure-logging.example.com', 6514),
socktype=socket.SOCK_STREAM,
secure={cafile='/path/to/ca/file'})
logger.addHandler(handler2)
# with custom SSLContext
context = ssl.create_default_context(cafile='/path/to/ca/file')
handler3 = TLSSysLogHandler(address=('secure-logging.example.com', 6514),
socktype=socket.SOCK_STREAM,
secure=context)
logger.addHandler(handler3)
# or allow TLS without verification
handler4 = TLSSysLogHandler(address=('secure-logging.example.com', 6514),
socktype=socket.SOCK_STREAM,
secure="noverify")
logger.addHandler(handler4)
logger.info('Hello World!')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tlssysloghandler-1.0.2.tar.gz
(6.5 kB
view hashes)
Built Distribution
Close
Hashes for tlssysloghandler-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 537e70ef96f1d3135b336b384317191b442b68c2d4d333099224bf42949ceb34 |
|
MD5 | 3f57beb5b3fa1c83d99c1c867a28a690 |
|
BLAKE2b-256 | 97abc87f6fa8b5cd8bfff11985c5d5c7a6ccf32f720218f5d6409ebdbcae2959 |