https://github.com/bodgergely/spdlog-python
python wrapper around C++ spdlog (git@github.com:gabime/spdlog.git)
https://github.com/bodgergely/spdlog-python
gabime logger logging pybind11 python python-wrapper spdlog
Last synced: 5 months ago
JSON representation
python wrapper around C++ spdlog (git@github.com:gabime/spdlog.git)
- Host: GitHub
- URL: https://github.com/bodgergely/spdlog-python
- Owner: bodgergely
- License: mit
- Created: 2018-02-18T00:33:46.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-20T15:21:52.000Z (over 1 year ago)
- Last Synced: 2025-05-19T22:25:56.555Z (6 months ago)
- Topics: gabime, logger, logging, pybind11, python, python-wrapper, spdlog
- Language: C++
- Homepage:
- Size: 162 KB
- Stars: 63
- Watchers: 5
- Forks: 20
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/bodgergely/spdlog-python/actions)
spdlog-python
=============
python wrapper around the fast C++ logger called [spdlog](https://github.com/gabime/spdlog)
Introduction
============
Python wrapper (pybind11) around the C++ spdlog logging library.
Why choose [spdlog](https://github.com/gabime/spdlog)?
https://kjellkod.wordpress.com/2015/06/30/the-worlds-fastest-logger-vs-g3log/
Try running [tests/spdlog_vs_logging.py](https://github.com/bodgergely/spdlog-python/blob/master/tests/test_spdlog.py) and see what results you get on your system.
spdlog-python vs logging (standard lib)
---------------------------------------
How many microseconds it takes on average to complete a log function (info(), debug() etc) using a FileLogger.
On reasonable sized log messages spdlog takes **4% (async mode enabled)** and **6% (sync mode)** of the time it would take to complete using the standard logging module.
Async mode with 8MB queue with blocking mode.
| msg len (bytes) | spdlog **sync** (microsec)| spdlog **async** (microsec)| logging (microsec) |
| ------- | :--------: | :--------: | :--------: |
| 10 | 1.2 | 0.87 | 24.6 |
| 100 | 1.2 | 1.03 | 24.6 |
| 300 | 1.5 | 1.07 | 24.9 |
| 1000 | 2.4 | 1.16 | 26.8 |
| 5000 | 6.2 | 2.31 | 31.7 |
| 20000 | 15.3 | 7.51 | 48.0 |
Installation
============
1) `pip install spdlog` will get a distribution from pypi.org
or
2) from github:
`pip install pybind11` - if missing
```bash
git clone https://github.com/bodgergely/spdlog-python.git
cd spdlog-python
git submodule update --init --recursive
python setup.py install
```
Usage
=====
```python
./python
import spdlog as spd
logger = spd.FileLogger('fast_logger', '/tmp/spdlog_example.log')
logger.set_level(spd.LogLevel.INFO)
logger.info('Hello World!')
logger.debug('I am not so important.')
```
To run the speed test:
```bash
python ./tests/spdlog_vs_logging.py
```