📄 mn_log.c
字号:
/***********************************************************
mn_log.c
-------------------
description : log function of management
begin : Wed April 25 2001
copyright : (C) 2001 by chenbin
email : chenbin@harbournetworks.com
*************************************************************/
#ifdef _cplusplus
extern"C"{
#endif
#include "mn_set.h"
#include "mn_log.h"
#include "mn_lib.h"
#include <linx_str.h>
long mn_log_flag;
void mn_log_flag_init(void)
{
mn_log_flag = 0;
mn_log_flag_set(_MN_LOG_SYS_);
return;
}
int mn_log_flag_set(long log_content_flag)
{
mn_log_flag |= log_content_flag;
return 1;
}
int mn_log_flag_unset(long log_content_flag)
{
mn_log_flag &= ~(log_content_flag);
return 1;
}
void mn_log(long log_content_flag,int log_type,int module_id, char *file_name,char *funcname,char *format,...)
{
char *logstr;
va_list args;
int len;
char buf[300];
char module_name[30];
if (!(log_content_flag & mn_log_flag))
{
return;
}
va_start(args,format);
memset(buf,0,300);
len = vsnprintf(buf,sizeof(buf),format,args);
logstr = (char *) kmalloc((len+1),module_id);
memset(logstr,0,(len+1));
memcpy(logstr,buf,len);
va_end(args);
memset(module_name,0,30);
mn_module_id_to_str(module_id,module_name);
syslog(log_type,"%s:%s:%s:%s\r\n",module_name,file_name,funcname,logstr);
kfree(logstr);
return ;
}
#ifdef _cplusplus
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -