easylogconfig
This python library provides simple wrapper for standart logging module.
If you want something more than "logging.basicConfig", but don't want to read a lot of documentation and write a lot of code.
WARNING Since v0.2 python 2 is not supported anymore.
Usage
You can find examples in ./examples directory
import logging
import easylogconfig
log = logging.getLogger(__name__)
# print messages to the stdout, add debug level
easylogconfig.auto(debug=True)
# or print messages to the syslog
easylogconfig.auto(syslog_tag="example_tag")
# or log messages to remote syslog server
easylogconfig.auto(syslog_tag="example_tag", syslog_address=("127.0.0.1", 514))
# or print messages to the file without datetime but with thread names
easylogconfig.auto(file_name="/var/log/example.log", file_backup_count=30,
datetime=False, thread=True)
log.info("info message")
log.debug("debug message")
# output format:
# 2019-03-22/10:17:28 INFO info message
Configuration
Library provides one simple function auto with arguments:
- formatter arguments:
- debug=False: add debug messages to output?
- thread=False: add thread names to messages?
- datetime=True: add datetime to messages?
- level=False: add level names to messages?
- SysLogHandler arguments:
- syslog_tag=None: if set to str, log messages to syslog with this tag
- syslog_address="/dev/log": syslog server address. By default, it sends syslog messages via
/dev/logfile. It can be set to string (ip address or hostname, in this case default 514 port is used), or to Tuple[str, int] (like logging.handlers.SysLogHandler)
- TimedRotatingFileHandler arguments:
- file_name=None: if set to str, log messages to this tile
- file_when="midnight": file rotating time
- file_backup_count=7: keep last files
Log handlers configuration rules:
- StreamHandler will be used if syslog_tag or file_name are omitted or empty strings
- SysLogHandler will be used if syslog_tag is set to none-empty string
- TimedRotatingFileHandler will be used if file_name is set to none-empty string
- ValueError will be raised if both syslog_tag and file_name are set to none-empty string
Installation
python3 -m pip install -U easylogconfig
# or
python3 -m pip install -U git+https://github.com/tierpod/easylogconfig#egg=easylogconfig
Development
make venv
source ./venv/bin/activate
(venv) make init-dev init
Metadata
Release files for easylogconfig 0.2.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 | Actions |
|---|---|---|---|---|
| easylogconfig-0.2.0.tar.gz | 4.1 kB | Without provenance | Details for easylogconfig-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| easylogconfig-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for easylogconfig-0.2.0-py3-none-any.whl |
Total release size: 8.5 kB
Release files / easylogconfig-0.2.0.tar.gz
| Download URL | easylogconfig-0.2.0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be7dd0a40feece59fc07240f6c8d7a839a96f964f532b42130d9f571654148e6
|
|
BLAKE2b-256 checksum How to use checksums |
3cd4459a0d65625e3b7d75ac1aed017e1026f07eb34cb4d5057d43dc8815acf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 CPython/3.10.6
|
Release files / easylogconfig-0.2.0-py3-none-any.whl
| Download URL | easylogconfig-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
032e2382cb9aae7e87d5f8eb9d12c8a715b68c0230c80870d28ea9342d7404ff
|
|
BLAKE2b-256 checksum How to use checksums |
296a8beb0dd40a89431e29191103629e6fde21e806214416ec679af8e9d4ed53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 CPython/3.10.6
|
Security for easylogconfig 0.2.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.