Skip to content

bodgergely/spdlog-python

Folders and files

NameName
Last commit message
Last commit date
Apr 10, 2023
May 2, 2022
Apr 30, 2024
Aug 14, 2019
Aug 2, 2019
Mar 26, 2019
Jan 5, 2019
Jan 5, 2019
Feb 18, 2018
Oct 19, 2020
Apr 10, 2023
Feb 12, 2021
Mar 2, 2018
Apr 19, 2023
Sep 5, 2019

Repository files navigation

Build Status

spdlog-python

python wrapper around the fast C++ logger called spdlog

Introduction

Python wrapper (pybind11) around the C++ spdlog logging library.

Why choose spdlog?

https://kjellkod.wordpress.com/2015/06/30/the-worlds-fastest-logger-vs-g3log/

Try running tests/spdlog_vs_logging.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

  1. from github:

pip install pybind11 - if missing

git clone https://github.com/bodgergely/spdlog-python.git
cd spdlog-python
git submodule update --init --recursive
python setup.py install

Usage

./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:

python ./tests/spdlog_vs_logging.py