b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

log4cpp_log4qt_log4j与log4cp区别(3)

电脑杂谈  发布时间:2016-12-26 03:02:23  来源:网络整理

{

if (log4c_category_is_priority_enabled(mycat, LOG4C_PRIORITY_TRACE))

{

a_list argptr;

va_start(argptr, format);

log4c_category_vlog(mycat, LOG4C_PRIORITY_TRACE, format, argptr);

va_end(argptr);

}

}

5.自定义Logout

5.1 添加在Log4c源代码中的流程

在log4c-1.2.0/src/文件夹添加相应的头文件和实现文件,如examplelayout.h和examplelayout.c文件

在am__liblog4c_la_SOURCES_DIST中添加examplelayout.c

在am_liblog4c_la_OECTS中添加examplelayout. lo

在liblog4c_la_SOURCES 中添加examplelayout.c

在pkginclude_HEADERS中添加 examplelayout.h

添加@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ examplelayout.Plo@am__quote@

在liblog4c_la_SOURCES中添加examplelayout.c

在pkginclude_HEADERS中添加examplelayout.h

添加#include <examplelayout.h>

在static const log4c_layout_type_t * const layout_types[]数组中添加新添加的layout_type函数指针

5.2在工程中添加自定义日志格式

实现自定义格式的主要函数:

static const char* cat_format(

const log4c_layout_t* a_layout,

const log4c_logging_event_t*a_event)

{

static char buffer[4096];

/*

* For this formatter we put the category up front in the log message

*/

sprintf(buffer, "[%s][LINE:%d][FILE:%s] %s", a_event->evt_category,

a_event->evt_loc->loc_line, a_event->evt_loc->loc_file, a_event->evt_msg);

return buffer;

}

const log4c_layout_type_t log4c_layout_type_cat= {

"test_cat", //格式名称,用于配置文件的设置

cat_format, //格式定义函数

5.3将自定义格式添加到Log4c的配置中:

5.4自定义格式的使用

//执行自定义格式初始化

#ff00806.自定义Appender

6.1实现自定义输出流的主要函数:

static int test_file_append(log4c_appender_t* a_appender,

const log4c_logging_event_t* a_event)

{

FILE* fp = log4c_appender_get_udata(a_appender);


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-23402-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...