https://github.com/suconbu/logu
Single header logging utility for C++
https://github.com/suconbu/logu
cpp cpp11 header-only logging single-header
Last synced: 12 months ago
JSON representation
Single header logging utility for C++
- Host: GitHub
- URL: https://github.com/suconbu/logu
- Owner: suconbu
- License: mit
- Created: 2022-02-05T14:23:33.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-23T15:03:27.000Z (over 3 years ago)
- Last Synced: 2025-01-27T11:13:50.694Z (over 1 year ago)
- Topics: cpp, cpp11, header-only, logging, single-header
- Language: C++
- Homepage:
- Size: 60.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# logu
The single header logging utility for C++.
Example:
```cpp
#include "logu/logu.h"
int main()
{
// Stream style
LOGU_DEBUG << "debug message";
LOGU_INFO << "info message";
LOGU_WARN << "warning message";
LOGU_ERROR << "error message";
LOGU << "message with no severity specified";
// Print variable name and value
int32_t age = 3;
std::string name = "taro";
LOGU_DEBUG << LOGU_VARS(name, age);
return 0;
}
```
Result:
```
2022-04-04 00:10:23.000 | DEBUG | 6793 | example.cpp@7 | debug message
2022-04-04 00:10:23.000 | INFO | 6793 | example.cpp@8 | info message
2022-04-04 00:10:23.000 | WARN | 6793 | example.cpp@9 | warning message
2022-04-04 00:10:23.000 | ERROR | 6793 | example.cpp@10 | error message
2022-04-04 00:10:23.000 | ----- | 6793 | example.cpp@11 | message with no severity specified
2022-04-04 00:10:23.000 | DEBUG | 6793 | example.cpp@17 | (name, age) -> (taro, 3)
```
Log format (default):
```
{date-time} | {severity} | {thiread-id} | {file-name}@{line-no} | {message}
```
Please see [example.cpp](/example/example.cpp) for example.
# Setup
1. Place `logu/logu.hpp` in include path of your project.
2. Add `#include "logu/logu.hpp"` into your source code.
# Lisence
MIT License.