https://github.com/shuai132/log
a simple printf wrapper for c/c++
https://github.com/shuai132/log
log logger logging printf
Last synced: 3 months ago
JSON representation
a simple printf wrapper for c/c++
- Host: GitHub
- URL: https://github.com/shuai132/log
- Owner: shuai132
- Created: 2019-08-03T06:38:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-07T11:31:09.000Z (11 months ago)
- Last Synced: 2025-03-21T02:41:30.833Z (10 months ago)
- Topics: log, logger, logging, printf
- Language: C++
- Size: 160 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# log
[](https://github.com/shuai132/LOG/actions?workflow=CI)
log for C/C++ project, by wrapper and enhance `printf`.
## Features
* One header file
* Colors on Unix
* Print filename and lines automatically
* Line feed with `\n`, or `\r\n` with `L_O_G_LINE_END_CRLF`
* Ignores `LOGD` in release mode
* Support thread safe and thread id
* Support DateTime
## Usage
[example](example.cpp)
```c++
#include "log.h"
int main() {
LOG("log");
LOGT("T", "msg with tag");
LOGD("debug");
LOGI("info");
LOGW("warn");
LOGE("error");
LOGF("fatal");
[] { LOGE("in lambda"); }();
return 0;
}
```
Output:
```text
2023-09-14 23:32:23.197 229765 [*]: example.cpp:4 log
2023-09-14 23:32:23.198 229765 [T]: example.cpp:5 msg with tag
2023-09-14 23:32:23.198 229765 [D]: example.cpp:6 debug
2023-09-14 23:32:23.198 229765 [I]: example.cpp:7 info
2023-09-14 23:32:23.198 229765 [W]: example.cpp:8 [main] warn
2023-09-14 23:32:23.198 229765 [E]: example.cpp:9 [main] error
2023-09-14 23:32:23.198 229765 [!]: example.cpp:10 [main] fatal
2023-09-14 23:32:23.198 229765 [V]: example.cpp:11 verbose
2023-09-14 23:32:23.198 229765 [E]: example.cpp:12 [operator()] in lambda
```