Global ]strict init false1024x768= 2MB lock file= /tmp/zlog. Lock "%d.%us [%v][%f:%l]%m%n"[rules]asr_level. * "/home/test/asr.log"; normal
NOTE: If you configure the Rotate lock file entry, in your own native test, be careful to delete the Zlog.lock file, or it may be locked, resulting in zlog initialization failure
Zlog parameter configuration details [formats]%d -represents time, such as 2018-07-20 09:32:43%us -Indicates subtlety, such as 991437%f -represents a file, such as Test_init.c%v --Indicates the log level, for example debug,info%l --Indicates the line number%m --Represents the user output information%n --Represents the line break normal = "%d.%us [%v][%f:%l]%m%n" [Rules] category name. * --Indicates that all levels of the log information class alias are printed. =debug --Indicates the log category name at the specified level is printed. Debug -Indicates a non-debug-level log is printed
#ifndef __asr_zlog_h_#define__asr_zlog_h_#include"zlog.h"/*Log Class*/externzlog_category_t *Zc;//Initialize ZlogintZloginit (Const Char*pcconfigpath,Const Char*pcmodelname);//Release Zlogvoidzlogdestory ();#defineFatal_log (fmt,...) \zlog_fatal (zc,fmt,__va_args__);#defineError_log (fmt,...) \Zlog_error (zc,fmt,__va_args__);#defineWarn_log (fmt,...) \Zlog_warn (zc,fmt,__va_args__);#defineNotice_log (fmt,...) \Zlog_notice (zc,fmt,__va_args__);#defineInfo_log (fmt,...) \Zlog_info (zc,fmt,__va_args__);#defineDebug_log (fmt,...) \Zlog_debug (zc,fmt,__va_args__);#endif
#include <stdarg.h>#include"asr_log.h"#include"comontype.h"zlog_category_t*Zc;/********************************************************zlog*********************************************** **********//******************************************************** Func name:initdate created:2018-7-20 Description: Initialization Input:Output:Return:error code Caution: *********************************************************/intZloginit (inConst Char*pcconfigpath,inConst Char*pcmodelname) { intIRet =Default_error; if(NULL = = Pcconfigpath | | NULL = =pcmodelname) {IRet=Param_error; returnIRet; } IRet=Zlog_init (Pcconfigpath); if(IRet) {printf ("Init fail"); returnDefault_error; } ZC=zlog_get_category (pcmodelname); if(!ZC) {printf ("zlog_get_category fail\n"); Zlog_fini (); returnDefault_error; } returnResult_ok;}/******************************************************** Func name:initdate created:2018-7-20 Description: Destroy Zlog Input:Output:Return:Caution: *********************************************************/voidzlogdestory () {Zlog_fini ();}
Linux Shared library Zlog logs