SystemLogger
..image:: https://pyup.io/repos/github/d9pouces/SystemLogger/shield.svg :target: https://pyup.io/repos/github/d9pouces/SystemLogger/ :alt: Updates
Create and configure a logger using a global configuration file. This module is intended for logging my Python system scripts, without redeclaring a lot of boilerplate. This module is not meant to be highly customizable, but to have the same logging configuration in scripts with a minimal effort.
The default configuration file is /etc/python_logging.ini.
Usage
python3 -m pip install systemlogger
cat << EOF | sudo tee /etc/python_logging.ini
[logging]
sentry_dsn = https://username@sentry.example.com/1
loki_url = https://username:password@localhost:3100/loki/api/v1/push
syslog_url = tcp://127.0.0.1:514
# only udp:// and tcp:// protocols can be used for syslog
logfile_directory = /tmp
# the filename will be /tmp/{application}.log
logfile_max_size = 1000000
# if max_size is not set (or is 0), the file will never be rotated
logfile_backup_count = 3
# number of backup files (for example, only /tmp/{application}.log.1 is created if logfile_backup_count == 1)
console = true
# errors and above are sent to stderr, infos and below are sent to stdout
level = info
# minimal level of transmitted log records
source = python
# added as "log_source" tag in sentry and loki
hostname = $(hostname)
# added as "hostname" tag in sentry and loki
requests_ca_bundle = /etc/ssl/certs/ca-certificates.crt
# path to the CA bundle for requests
EOF
python3 -c 'from systemlogger import getLogger ; logger = getLogger(name="demo") ; logger.warning("log warning test") ; logger.error("log error test")'
In Grafana/Loki and in Sentry, you can now select all Python scripts with the log_source tag and a specific script
with
the application tag.
Metadata
Release files for SystemLogger 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| systemlogger-0.2.2.tar.gz | 12.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| systemlogger-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.6 kB
Release files / systemlogger-0.2.2.tar.gz
| Download URL | systemlogger-0.2.2.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42ec571ea7c514d92ceae064d164018bdd7f24aa2a24d06a9b79b3188e910508
|
|
BLAKE2b-256 checksum How to use checksums |
5747467673982e7169e0d6991c436366afe092e6eb0d7ee07ddcd0e4777803ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.13.1 Darwin/24.3.0
|
Release files / systemlogger-0.2.2-py3-none-any.whl
| Download URL | systemlogger-0.2.2-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
863daf6944cc2276907f7f479a43e87d484650a7343e958817229f029b69904a
|
|
BLAKE2b-256 checksum How to use checksums |
dbf894a9658ab1264274a60baa6d198060de574418610e3d8d88c2dc594a4b65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.13.1 Darwin/24.3.0
|