2014-07-11 22:12:11 +02:00
|
|
|
/*
|
|
|
|
This file is part of libcapwap.
|
|
|
|
|
|
|
|
libcapwap is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
libcapwap is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
*/
|
2015-03-15 20:53:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*@file
|
|
|
|
*@brief Definitions for logging and debugging.
|
|
|
|
*/
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
#ifndef __CW_LOG_H
|
|
|
|
#define __CW_LOG_H
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <syslog.h>
|
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
#ifndef LOG_ERROR
|
|
|
|
#define LOG_ERROR LOG_ERR
|
|
|
|
#endif
|
|
|
|
|
2015-04-10 19:51:56 +02:00
|
|
|
#ifndef CW_LOG_DEFAULT_LOG
|
|
|
|
#define CW_LOG_DEFAULT_LOG cw_log_file
|
|
|
|
#endif
|
|
|
|
#ifndef CW_LOG_DEFAULT_VLOG
|
|
|
|
#define CW_LOG_DEFAULT_VLOG cw_log_vfile
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-14 10:04:44 +02:00
|
|
|
|
2015-03-15 20:53:21 +01:00
|
|
|
|
2014-08-14 10:04:44 +02:00
|
|
|
|
2015-04-11 19:00:51 +02:00
|
|
|
//extern void cw_log_dbg_(int type, const char *file, int line, const char *fromat, ...);
|
|
|
|
//extern void cw_log_dbg_dmp_(int type, const char *file, int line, const uint8_t * data,
|
|
|
|
//int len, const char *format, ...);
|
2014-08-17 11:37:18 +02:00
|
|
|
|
2014-08-14 11:25:06 +02:00
|
|
|
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
#ifdef WITH_CW_LOG
|
2015-04-10 19:51:56 +02:00
|
|
|
#define cw_log(level,...) cw_log_colored(level,__VA_ARGS__)
|
2014-07-11 22:12:11 +02:00
|
|
|
#else
|
2015-04-10 17:52:01 +02:00
|
|
|
#define cw_log(...)
|
2014-07-11 22:12:11 +02:00
|
|
|
#endif
|
|
|
|
|
2015-04-11 19:00:51 +02:00
|
|
|
//#ifdef WITH_CW_LOG_DEBUG
|
2015-03-29 01:55:06 +01:00
|
|
|
|
2014-08-14 10:04:44 +02:00
|
|
|
|
2015-04-11 19:00:51 +02:00
|
|
|
//#define cw_log_dbg(type,...) cw_log_dbg_(type,__FILE__,__LINE__,__VA_ARGS__)
|
2014-08-14 10:04:44 +02:00
|
|
|
|
2015-03-29 01:55:06 +01:00
|
|
|
|
2014-08-14 10:04:44 +02:00
|
|
|
|
2015-04-11 19:00:51 +02:00
|
|
|
//#define cw_log_dbg_dmp(type,str,len,...) cw_log_dbg_dmp_(type,__FILE__,__LINE__,str,len,__VA_ARGS__)
|
|
|
|
//#define cw_dbg_dmp(type,str,len,...) cw_log_dbg_dmp_(type,__FILE__,__LINE__,str,len,__VA_ARGS__)
|
2014-08-25 23:39:26 +02:00
|
|
|
|
2015-04-11 19:00:51 +02:00
|
|
|
//#define cw_dbg_msgelem(msgtype,msgelemtype,msgbuf,msglen) cw_dbg_msgelem_(msgtype,msgelemtype,msgbuf,msglen)
|
|
|
|
//#define cw_dbg_missing_mand_elems(conn, msgtyoe, mand) cw_dbg_missing_mand_elems_(conn, msgtyoe, mand)
|
|
|
|
|
|
|
|
//#define lw_dbg_elem(msgtype,msgelemtype,msgbuf,msglen) lw_dbg_elem_(msgtype,msgelemtype,msgbuf,msglen)
|
|
|
|
|
|
|
|
//#else
|
|
|
|
//#define cw_log_dbg(...)
|
|
|
|
//#define cw_dbg(...)
|
|
|
|
|
|
|
|
//#define cw_dbg_missing_mand_elems(conn, msgtyoe, mand)
|
|
|
|
|
|
|
|
//#endif
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-04-10 17:52:01 +02:00
|
|
|
extern void (*cw_log_cb) (int level, const char *fromat, ...);
|
2015-04-11 19:00:51 +02:00
|
|
|
extern void (*cw_log_vcb) (int level, const char *fromat, va_list args);
|
2015-04-10 19:51:56 +02:00
|
|
|
|
|
|
|
/* Syslog functins */
|
|
|
|
extern void cw_log_syslog(int level, const char *format, ...);
|
|
|
|
extern void cw_log_vsyslog(int level,const char * format, va_list args);
|
|
|
|
|
|
|
|
/* Log to File functions */
|
|
|
|
void cw_log_vfile(int level,const char * format, va_list args);
|
|
|
|
void cw_log_file(int level,const char *format, ...);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cw_log_colored(int level, const char *format, ...);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//extern void (*cw_log_debug_cb) (int type, const char *format, ...);
|
2014-08-14 10:04:44 +02:00
|
|
|
|
2015-04-10 19:51:56 +02:00
|
|
|
//extern void (*cw_log_debug_cbs[]) (const char *fromat, ...);
|
2015-04-10 17:52:01 +02:00
|
|
|
extern int cw_log_debug_dump_(int level, const uint8_t * data, int len,
|
|
|
|
const char *format, ...);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-14 10:04:44 +02:00
|
|
|
|
2015-04-10 17:52:01 +02:00
|
|
|
extern void cw_dbg_msgelem_(int msg, int msgelem, const uint8_t * msgbuf, int len);
|
2015-03-29 01:55:06 +01:00
|
|
|
|
|
|
|
|
2014-08-25 23:39:26 +02:00
|
|
|
struct conn;
|
2015-04-10 17:52:01 +02:00
|
|
|
extern void cw_dbg_missing_mand_elems_(struct conn *conn, int msgtyoe, int *mand);
|
2014-08-21 21:16:55 +02:00
|
|
|
|
2015-04-10 17:52:01 +02:00
|
|
|
extern void lw_dbg_elem(int msg_id, int elem_id, const uint8_t * elem_data, int elem_len);
|
2014-08-21 21:16:55 +02:00
|
|
|
|
2014-08-14 10:04:44 +02:00
|
|
|
extern int cw_log_debug_level;
|
2015-04-10 17:52:01 +02:00
|
|
|
extern int cw_log_str2dbglevel(const char *str);
|
2014-08-14 10:04:44 +02:00
|
|
|
|
|
|
|
|
2015-04-10 17:52:01 +02:00
|
|
|
extern const char *cw_log_name;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-04-10 17:52:01 +02:00
|
|
|
struct cw_dbg_cfgstrs {
|
2015-02-08 13:29:56 +01:00
|
|
|
const char *name;
|
|
|
|
int level;
|
2015-04-10 17:52:01 +02:00
|
|
|
};
|
2015-02-08 13:29:56 +01:00
|
|
|
|
|
|
|
extern struct cw_dbg_cfgstrs cw_dbg_cfgstrs[];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-10 17:52:01 +02:00
|
|
|
#endif
|