• 文章
  • 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]