A standardised logging configuration I use for a few things.
Project description
python-logsy
A standardised logging configuration I use for a few things.
Quickstart
-
Install this package with optional extras:
pip install python-logsy[fluent,sentry]
-
Import and configure. This package has three logging handlers available in the default configuration. All are relatively self-explanatory except that the
fluenthandler logs to a Fluentd or Fluent Bit instance and requires thefluentdependencies to be installed via the optional extras. Furthermore, thefilehandler useslogging.handlers.RotatingFileHandler. Log files will rollover at 100 megabytes when using thefilehandler.import logging import logsy config = { 'loggers': { 'app': { 'handlers': ['console', 'fluent', 'file'], 'level': 'INFO', 'propagate': True, }, }, } logsy.init( config, tag='apps.myapp', # Also used as the Fluent tag (routing) fluent_host='localhost', environment='production', release='2.1.1-beta', )
-
A complete example of
init; including setup for Sentry:logsy.init( config, tag='apps.myapp', # Also used as the Fluent tag (routing) replace_config=False, fluent_host='localhost', fluent_port=24224, # default async_fluent=True, # default environment='debug', debug=True, # default is False release='2.1.1-beta', level=logging.INFO, # default sentry_config={ 'dsn': 'fake-dsn-string', 'traces_sample_rate': 1.0, # default }, )
-
Log as per usual:
import logging logger = logging.getLogger(__name__) logger.info('Testing')
-
If needed, replace the default logging config with your own:
config = { 'version': 1, 'disable_existing_loggers': False, 'formatters': {}, # incomplete 'handlers': {}, # incomplete } logsy.init( config, replace_config=True, tag='apps.myapp', fluent_host='localhost', fluent_port=24224, # default environment='debug', debug=True, # default is False release='2.1.1-beta', level=logging.INFO, # default )
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_logsy-0.2.0.tar.gz.
File metadata
- Download URL: python_logsy-0.2.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63497185703ac30055ef0d5c4095c643fa95b1baf1578ba07c2330612db2308f
|
|
| MD5 |
e16267428ac69abdc63cd0aebca1e4d2
|
|
| BLAKE2b-256 |
2b9f77f1f5c581aff201cafd095cebd67260c1a6e86aabff883ee4aedaafcc6c
|
File details
Details for the file python_logsy-0.2.0-py3-none-any.whl.
File metadata
- Download URL: python_logsy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52d40288db6dc6841223d7be4a24d3cbbda19b1b42b4be91a886c12025db83fd
|
|
| MD5 |
f4c49c4189d9af52e25976f2b495f4e1
|
|
| BLAKE2b-256 |
087e8956d001decb83a684d2e2c2777bc81e6df5c162648d900d4678b11535f0
|