https://github.com/mysterious-ben/logutil
Simplified initializations for logging and loguru
https://github.com/mysterious-ben/logutil
logging loguru pushover sentry slack
Last synced: about 2 months ago
JSON representation
Simplified initializations for logging and loguru
- Host: GitHub
- URL: https://github.com/mysterious-ben/logutil
- Owner: mysterious-ben
- License: apache-2.0
- Created: 2020-07-19T05:16:08.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-02-02T08:00:12.000Z (over 1 year ago)
- Last Synced: 2025-02-02T08:26:00.585Z (over 1 year ago)
- Topics: logging, loguru, pushover, sentry, slack
- Language: Python
- Homepage:
- Size: 110 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logutil
(Extremely) easy initialization for `logging` and `loguru`
## Why
This packages makes it (extremely) easy to send `logging` and `loguru` logs to
- streams
- files
- sentry
- pushover
- slack
## Installation
- Logging only: `pip install logutil`
- ... + loguru: `pip install logutil[loguru]`
- ... + pushover/sentry/slack: `pip install logutil[notifiers]`
- ... + loguru + pushover/sentry/slack: `pip install logutil[all]`
## Examples
### Standard python logging
```python
from logutil import init_logging, get_logging_logger
init_logging(
name='data_feeds',
sentry_on=True,
sentry_dsn='',
sentry_breadcramp_level='INFO',
sentry_event_level='WARNING',
)
logger = get_logging_logger('data_feeds')
logger.info('Test INFO message (logging)')
logger.warning('Test WARNING message (logging)')
```
```
2020-07-19T12:59:18.740Z data_feeds INFO: Test INFO message (logging)
2020-07-19T12:59:18.740Z data_feeds WARNING: Test WARNING message (logging)
```
### Loguru
```python
from logutil import init_loguru, get_loguru_logger
init_loguru()
logger = get_loguru_logger(
slack_on=True,
slack_level='WARNING',
slack_webhook_url='',
)
logger.info('Test INFO message (loguru)')
logger.warning('Test WARNING message (loguru)')
```
```
2020-07-19T12:56:20.771Z __main__ INFO: Test INFO message (loguru)
2020-07-19T12:56:20.771Z __main__ WARNING: Test WARNING message (loguru)
```
## Notes
- Formatting is ignored for `sentry` notifications with `logging`