Looking for a simple logger for your C++ project? SimpleLogger
might be for you.
- Based on RAII
- Configurable level symbols
- Datetime / EPOCH timestamps
- Logging levels:
Trace
,Debug
,Info
,Warning
,Error
,Fatal
- Log to file and/or console
- Thread-safe
- Uses streams (<< operator)
- Very easy to use
Just add src/simple_logger.hpp
and src/simple_logger.cpp
to your project and start using it!
Add the CMake project as a subproject or build and install:
$ mkdir build && cd build
$ cmake ..
$ make
$ sudo make install
Note: instead of Logger
class you can simply use L
.
using juzzlin::L;
L().info() << "Something happened";
Outputs something like this:
Sat Oct 13 22:38:42 2018 I: Something happened
using juzzlin::L;
L::init("/tmp/myLog.txt");
L().info() << "Something happened";
using juzzlin::L;
L::init("/tmp/myLog.txt");
L::enableEchoMode(false);
L().info() << "Something happened";
using juzzlin::L;
L::setLoggingLevel(L::Level::Debug);
L().info() << "Something happened";
L().debug() << "A debug thing happened";
Outputs something like this:
Sat Oct 13 22:38:42 2018 I: Something happened
Sat Oct 13 22:38:42 2018 D: A debug thing happened
using juzzlin::L;
L::setLoggingLevel(L::Level::Debug);
L::setLevelSymbol(L::Level::Debug, "<DEBUG>");
L().debug() << "A debug thing happened";
Outputs something like this:
Sat Oct 13 22:38:42 2018 <DEBUG> A debug thing happened
Possible modes: None
, EpochSeconds
, EpochMilliseconds
, EpochMicroseconds
, DateTime
.
using juzzlin::L;
L::setTimestampMode(L::TimestampMode::EpochMilliseconds, " ## ");
L().info() << "Something happened";
Outputs something like this:
1562955750677 ## I: Something happened
C++11
MIT