簡介
Log4z 是一個開源的 C++ 輕量級日誌庫。
它在 C++ 應用程式中提供了日誌和除錯跟蹤功能。
使用 log4z 可以非常簡單方便地除錯日誌或追蹤資訊,將資訊輸出到螢幕、日誌檔案
開源站點
https://github.com/zsummer/log4z
log4z 的優點
1. 極寬鬆的 MIT 開源許可,可無限制地用於個人、教育和商業場合
2. log4z 非常輕量。使用 C++ 及系統 API 編寫,僅需要一個頭檔案和一個 CPP 原始檔,非常簡單易用
3. 適用於跨平臺(Windows 或 Linux,32 或 64 位)多執行緒日誌輸出場合
4. 提供完整的日誌優先順序控制,並且可以在任何位置調整程式
5. 透過配置檔案或呼叫介面,可增加帶有不同配置的日誌記錄器
6. 螢幕輸出根據優先順序顯示不同的日誌顏色,檔案輸出資訊夠整潔,日誌介面快速便捷
7. 效能出色,記憶體佔用小
8. 介面清晰簡單,熟練的程式設計師只需要瀏覽 log4z.h 介面即可掌握該日誌系統。
更新日誌
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
/*
* UPDATES
*
* VERSION 0.1.0 <DATE: 2010.10.4>
* create the first project.
* It support put log to screen and files,
* support log level, support one day one log file.
* support multiple thread, multiple operating system.
*
* VERSION .... <DATE: ...>
* ...
*
* VERSION 0.9.0 <DATE: 2012.12.24>
* support config files.
* support color text in screen.
* support multiple logger.
*
* VERSION 1.0.0 <DATE: 2012.12.29>
* support comments in the config file.
* add a advanced demo in the ./project
* fix some details.
*/
|
快速使用者手冊
1. include log4z.h
2. using namespace
using namespace zsummer::log4z;
3. add a logger. if skip that only one main logger.
ILog4zManager::GetInstance()->AddLogger(1,"", "AddLogger", LOG_DEBUG);
4. start log4z.
ILog4zManager::GetInstance()->Start();
5. fast log record micro: LOGD LOGI LOGE ... It's record to main logger, and the level is LOG DEBUG, LOG INFO ... example:
LOGD("this is a LOG_DEBUG level's log, " << " ^_^ " );
6. stop and close. Log4z will auto stop and close at the process dea.
//ILog4zManager::GetInstance()->Stop()
|
編譯
in VS join the .h and .cpp
in linux, need append -lpthread. example:
g++ -lpthread -o test main.cpp ../log4z.cpp
|
// 增加了 log4z v1.0.1
1 2 3 4 5
|
* VERSION 1.0.1 <DATE: 2013.01.01>
* the source code haven't any change.
* fix some Comments in the log4z
* add some comments in the test projects.
* delete some needless code in the 'fast_test' demo projects, it's so simple.
|
附件: [log4z_v1.0.0.zip] [log4z_v1.0.1.zip]