-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
SimpleLogger | ||
============ | ||
|
||
Looking for a simple logger for C++ ? SimpleLogger might be for you. | ||
|
||
# Features | ||
|
||
* Based on RAII | ||
* Configurable level symbols | ||
* Date / time | ||
* Logging levels: Trace, Debug, Info, Warning, Error, Fatal | ||
* Log to file and/or console | ||
* Very easy to use | ||
|
||
# Installation | ||
|
||
Just add `src/logger.hpp` and `src/logger.cpp` to your project and start using it! | ||
|
||
# Examples | ||
|
||
## Log to console | ||
|
||
``` | ||
using juzzlin::L; | ||
L().info() << "Something happened"; | ||
``` | ||
|
||
Outputs something like this: | ||
|
||
`[Sat Oct 13 22:38:42 2018] I: Something happened` | ||
|
||
## Log to file and console | ||
|
||
``` | ||
using juzzlin::L; | ||
L::init("/tmp/myLog.txt"); | ||
L().info() << "Something happened"; | ||
``` | ||
|
||
## Log only to file | ||
|
||
``` | ||
using juzzlin::L; | ||
L::init("/tmp/myLog.txt"); | ||
L::enableEchoMode(false); | ||
L().info() << "Something happened"; | ||
``` | ||
|
||
## Set logging level | ||
|
||
``` | ||
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` | ||
|
||
## Set custom level symbols | ||
|
||
``` | ||
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` | ||
|
||
## Requirements | ||
|
||
C++11 | ||
|
||
## Licence | ||
|
||
MIT |