https://github.com/berquerant/pylog
A light-weight wrapper of standard log.
https://github.com/berquerant/pylog
python
Last synced: 3 months ago
JSON representation
A light-weight wrapper of standard log.
- Host: GitHub
- URL: https://github.com/berquerant/pylog
- Owner: berquerant
- License: mit
- Created: 2022-10-11T12:04:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-28T21:09:44.000Z (about 1 year ago)
- Last Synced: 2025-04-28T22:34:35.713Z (about 1 year ago)
- Topics: python
- Language: Python
- Homepage:
- Size: 419 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pylog
A light-weight wrapper of standard log.
## Library
``` python
import pylog
import logging
logging.basicConfig(level=logging.DEBUG)
pylog.info("msg")
m = pylog.Mapper(lambda e: e.update(fmt=f"mapped {e.fmt}")) + pylog.LoggingLogger.consumer
pylog.LoggingLogger(m).info("msg")
def print_event(ev: pylog.Event):
print(str(ev))
m += print_event
pylog.LoggingLogger(m).info("print ev")
# Output:
# INFO:root:msg
# INFO:root:mapped msg
# INFO:root:mapped print ev
# mapped print ev
```
## CLI
``` shell
$ seq 0 3 | python -m pylog.cli 'datetime(2022,10,11,hour=12)+timedelta(hours=int(x))' -i 'from datetime import datetime,timedelta'
2022-10-11 12:00:00
2022-10-11 13:00:00
2022-10-11 14:00:00
2022-10-11 15:00:00
```
Help: `python -m pylog.cli -h`
## Dev
``` bash
./bin/build_docker.sh
# run test
./bin/pipenv.sh make test
```