Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aib/nice_logging
https://github.com/aib/nice_logging
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/aib/nice_logging
- Owner: aib
- License: mit
- Created: 2023-07-23T08:29:07.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-03-12T17:38:51.000Z (10 months ago)
- Last Synced: 2024-12-19T15:51:59.589Z (26 days ago)
- Language: Python
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nice_logging
Simple logging library that has colored and timestamped output by default. Can be used as a drop-in replacement.
## Installation
```pip install nice_logging```
(Or just grab the .py file)
## Usage
```python
import nice_logging
nice_logging.basicConfig(level=nice_logging.DEBUG)
logger = nice_logging.getLogger(__name__)
logger.info("Hello")
```
```
2023-07-23 11:27:33,571 [INFO ] [__main__] Hello
```Or:
```python
import nice_logging as logging
```## Structured Logging
nice_logging has support for rudimentary structured logging. If you use `getStructuredLogger` instead of `getLogger` (or instantiate a `StructuredLogger`), you will get a logger whose log functions take a single message, and any number of keyword arguments, which are aggregated in a single dict. The resulting `LogRecord` will have the attribute `structured` set to `True`, and `structured_data` to the dict.