gelfguru
A Loguru extension for handling log messages and adapt to GELF payload pattern, without modifying built-in Loguru methods call. This library was created especially for applications running in Docker environment with GELF Logging Driver.
Features:
- Dont modify call methods Loguru, like
logger.trace,logger.info,logger.infoetc; - Create new methods for
loggerinstance, with all RFC-5424 Severity level; - Associates RFC-5424 Severity Levels Numerical Codes in GELF field.
- Filter logs by environment variable
GELFGURU_LEVEL.
Installation
pip3.7 install gelfguru
How to Use
If you configure Loguru instance with gelfguru, you only need to execute:
from loguru import logger
from gelfguru import configure_gelf_output
configure_gelf_output()
logger.trace('loguru trace calls equals gelfguru debug calls')
logger.info('Numeric level RFC-5424')
logger.emergency('Implemented RFC-5424 Syslog Severity Logs')
Log Levels
GELF log level is equal to the standard syslog levels.
| gelfluru | Syslog Severity | Numerical Code | Description |
|---|---|---|---|
emergency |
Emergency | 0 | System is unusable. A panic condition |
alert |
Alert | 1 | Action must be taken immediately. A condition that should be corrected immediately, such as a corrupted system database.[ |
critical |
Critical | 2 | Critical conditions. Hard device errors |
error |
Error | 3 | Error conditions. |
warning |
Warning | 4 | Warning conditions |
success, notice |
Notice | 5 | Normal but significant condition. Conditions that are not error conditions, but that may require special handling |
info |
Informational | 6 | Informational messages |
debug, trace |
Debug | 7 | Debug-level messages. Messages that contain information normally of use only when debugging a program. |
Example:
from loguru import logger
from gelfguru import configure_gelf_output
configure_gelf_output()
logger.trace('loguru trace calls equals gelfguru debug calls')
# {
# "version": "1.1",
# "short_message": "trace\n",
# "full_message": "trace\n",
# "timestamp": 1593137655.309429,
# "level": 7,
# "line": 1,
# "_file": "<ipython-input-4-698cb139534b>",
# "_context": {
# "module": "__main__:<module>:1",
# "process": "MainProcess",
# "thread": "MainThread"
# }
# }
logger.info('Change numeric level value, in the case, is used RFC-5424 numeric level value')
# {
# "version": "1.1",
# "short_message": "Change numeric level value, in the case, is used RFC-5424",
# "full_message": "Change numeric level value, in the case, is used RFC-5424 numeric level value",
# "timestamp": 1593137655.42884,
# "level": 6,
# "line": 1,
# "_file": "<ipython-input-5-d527b5b194dc>",
# "_context": {
# "module": "__main__:<module>:1",
# "process": "MainProcess",
# "thread": "MainThread"
# }
# }
logger.emergency('Implemented RFC-5424 Syslog Severity Logs')
# {
# "version": "1.1",
# "short_message": "Implemented RFC-5424 Syslog Severity Logs",
# "full_message": "Implemented RFC-5424 Syslog Severity Logs",
# "timestamp": 1593137657.236526,
# "level": 0,
# "line": 1,
# "_file": "<ipython-input-6-5c45ca4c1de6>",
# "_context": {
# "module": "__main__:<module>:1",
# "process": "MainProcess",
# "thread": "MainThread"
# }
# }
logger.bind(new_field="i am additional filed gelf").error('iste natus error sit')
# {
# "version": "1.1",
# "short_message": "iste natus error sit",
# "full_message": "iste natus error sit",
# "timestamp": 1593138435.430722,
# "level": 3,
# "line": 18,
# "_file": "/home/augustoliks/github/loguru-gelf-extension/tests/test_loguru_gelf_extension.py",
# "_context": {
# "module": "test_loguru_gelf_extension:test_loguru_calls:18",
# "process": "MainProcess",
# "thread": "MainThread"
# },
# "_new_field": "i am additional filed gelf"
# }
Metadata
Release files for gelfguru 0.1.3
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 | |
|---|---|---|---|---|
| gelfguru-0.1.3.tar.gz | 8.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gelfguru-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.6 kB
Release files / gelfguru-0.1.3.tar.gz
| Download URL | gelfguru-0.1.3.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7173beaf862ce0d5bfc94cdf5906fe616b10ed4c7a7d2ab08802fb5015e9b38d
|
|
BLAKE2b-256 checksum How to use checksums |
0215ec49aa818560759e05866630f749601fa379564150054cc5f32528bc64a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.7.7 Linux/5.6.15-200.fc31.x86_64
|
Release files / gelfguru-0.1.3-py3-none-any.whl
| Download URL | gelfguru-0.1.3-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f9636dbfbac083eede6011164a0ff4ddde8cc20555742f36d7ef951f25d81568
|
|
BLAKE2b-256 checksum How to use checksums |
282936d571eec2ccaac1a5e3c49b07754815e04d4ecb0276e8fc281405911901
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.7.7 Linux/5.6.15-200.fc31.x86_64
|
Security for gelfguru 0.1.3
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.