The Principal Dev – Masterclass for Tech Leads

The Principal Dev – Masterclass for Tech LeadsJuly 17-18

Join

Build Status

C logger

Table of Contents

What is this?

This is a simple logging library for C/C++.

This library's main features:

Installation

./build.sh
cd build
make
sudo make install

or

build.bat

or

Copy files in src directory to your project

Platform

Note: Operations are confirmed on the above platforms

Benchmark

This following table comparing other libraries is benchmark results to log 1,000,000 times.

threads c-logger glog
1 0.832s 1.267s
10 1.386s 1.183s

Benchmark environment

Log format

level yy-MM-dd hh:mm:ss:uuuuuu threadid file:line: message

Example

Console logging

logger_initConsoleLogger(stderr);
logger_setLevel(LogLevel_DEBUG);
LOG_INFO("console logging");

File logging

logger_initFileLogger("logs/log.txt", 1024 * 1024, 5);
logger_setLevel(LogLevel_DEBUG);
LOG_INFO("file logging");
LOG_DEBUG("format example: %d%c%s", 1, '2', "3");

The output of the file logger is the following:

I 15-11-10 00:32:43.771455 2854 filelogger.c:6: file logging
D 15-11-10 00:32:43.771564 2854 filelogger.c:7: format example: 123

Multi logging

logger_initConsoleLogger(NULL);
logger_initFileLogger("logs/log.txt", 0, 0);
LOG_INFO("multi logging");

License

The MIT license

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.