• 文章
  • log4z v1.2.0 稳定版发布
发布
2013年4月8日 (最后更新: 2013年4月15日)

log4z v1.2.0 稳定版发布

评分: 4.1/5 (53 票)
*****

简介

Log4z 是一个开源的 C++ 轻量级日志库。它为 C++ 应用程序提供了日志和跟踪调试功能。使用 log4z 可以非常简单方便地进行调试日志或跟踪,将信息输出到屏幕、日志文件

开源站点

https://github.com/zsummer/log4z
标签

https://github.com/zsummer/log4z/tags

log4z 的优势


1. MIT 开源协议,非常宽松。
2. 轻量级且跨平台。
3. 完善的优先级级别控制。
4. 多日志输出,线程安全。
5. 完整的配置文件。
6. 屏幕输出带有不同颜色。


fast_test.cpp : 简单的演示

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "../log4z.h"
#include <iostream>
#include <stdio.h>
using namespace zsummer::log4z;

int main(int argc, char *argv[])
{

	//start log4z
	ILog4zManager::GetInstance()->Start();

	//LOGD: LOG WITH level LOG_DEBUG
	//LOGI: LOG WITH level LOG_INFO
	//...
	LOGD(" *** " << "hellow wolrd" <<" *** ");
	LOGI("loginfo");
	LOGW("log warning");
	LOGE("log err");
	LOGA("log alarm");
	LOGF("log fatal");
	LOGD("char:" <<'c'
		<< ", unsigned char:" << (unsigned char) 'c'
		<< ", short:" << (short) -1
		<< ", unsigned short:" << (unsigned short) -1
		<< ", int:" << (int) -1
		<< ", unsigned int:" << (unsigned int) -1
		<< ", long:" << (long) -1
		<< ", unsigned long:" << (unsigned long) -1
		<< ", long long:" << (long long) -1
		<< ", unsigned long long:" << (unsigned long long) -1
		<< ", float:" << (float) -1.234567
		<< ", double:" << (double) -2.34566
		<< ", std::string:" << std::string("fffff")
		<< ", void *:" << ( int *) argv
		<< ", const void*:" << (const int *) argv
		<< ", constant:" << 1000 
		<< ", constant:" << 100.12345678
		<< ", bool:" << (bool) true);
	LOGA("press anykey to exit ...");
	getchar();
	return 0;
}



编译


in VS join the log4z.h and log4z.cpp
in linux, need append -lpthread. example:
g++ -lpthread -o test main.cpp ../log4z.cpp

截图



log4z_log_tree





log4z_windows_fast_output






log4z_linux_fast_output




更新日志

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * 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.
 *
 * 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.
 *
 * VERSION 1.1.0 <DATE: 2013.01.24>
 * 	the method Start will wait for the logger thread started.
 *	config and add method change. 
 *	namespace change.
 *	append some macro.
 *
 * VERSION 1.1.1 <DATE: 2013.02.23>
 * 	add GetStatus**** mothed.
 *	optimize. 
 * VERSION 1.2.0 <DATE: 2013.04.05>
 *  optimize.
 *
 */



version 1.2.1 fix some detail bug from v1.2.0 optimize.
1. need include  <stdio.h> in header file.
2. new string stream format class on format <unsigned int> type  will more append  character 'd' .

附件: [log4z-1.2.0.zip] [log4z-1.2.1.zip]