简介
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]