| #ifndef _SOFTAP_LOG_H_ |
| #define _SOFTAP_LOG_H_ |
| #define _POSIX_C_SOURCE 199309 |
| #include <stdio.h> |
| #include <string.h> |
| #include <signal.h> |
| #include <sys/types.h> |
| #include <unistd.h> |
| #include <stdlib.h> |
| #include <stdarg.h> |
| #include "cfg_api.h" |
| |
| #define SIG_LOGLEV (SIGRTMIN + 1) |
| |
| #define LOG_OFF 0 |
| #define LOG_ON 0xff |
| |
| /* |
| * ´òÓ¡µÈ¼¶ |
| */ |
| #define SLOG_DEBUG 1 //Ñз¢¸öÌåÐÐΪlogÊä³ö£¬Á¿ºÜ´ó |
| #define SLOG_NORMAL 2 //¼¯³É²âÊÔ½×¶ÎlogÊä³ö£¬Á¿ÊÊÖÐ |
| #define SLOG_ERR 3 //ÖÂÃü»ò¿ìÕÕÀàlogÊä³ö£¬Á¿Ð¡ |
| #define SLOG_OFF 4 //È«²¿¹Ø±Õ´òÓ¡ |
| |
| #define SLOG_SOCTIME_OFF 0 |
| #define SLOG_SOCTIME_ON 1 |
| |
| #define NET_PRINT "[net]" |
| #define AT_PRINT "[at]" |
| #define MMI_PRINT "[mmi]" |
| #define MISC_PRINT "[misc]" |
| #define SDCARD_PRINT "[sdcard]" |
| #define USBCFGMNG_PRINT "[usbcfgmng]" |
| #define FLUXSTAT_PRINT "[fluxstat]" |
| #define WIFI_PRINT "[wifi]" |
| #define RTC_PRINT "[rtc]" |
| #define TR069_PRINT "[tr069]" |
| #define PB_PRINT "[pb]" |
| #define SMS_PRINT "[sms]" |
| #define MISC_MBIM "[mbim]" |
| #define DRVCOMMNG_PRINT "[drvcommng]" |
| #define SOCKET_PRINT "[socket]" |
| extern int asprintf(char **strp, const char *fmt, ...); |
| |
| /** |
| * @brief ͳһ¶ÏÑÔËÀ»ú½Ó¿Ú£¬½«ËÀ»úÔÒòechoµ½ÄÚºËsoftap_assert½ÚµãÖУ¬¶ÔÓ¦Äں˵ÄassertÈ«¾Ö±äÁ¿ÖÐ |
| */ |
| #if 0//klocwork |
| #define softap_assert(...) do { \ |
| char *p,*t; \ |
| if (-1 == asprintf(&p, __VA_ARGS__)) { \ |
| char tmp[128] = {0}; \ |
| sprintf(tmp,"echo \"%s:%d \">/proc/softap_assert", \ |
| __FUNCTION__, __LINE__); \ |
| system(tmp); \ |
| bzero(tmp, 128); \ |
| sprintf(tmp,"echo \"%s:%d \">/cache/net_last_asrt.txt", \ |
| __FUNCTION__, __LINE__); \ |
| system(tmp); \ |
| }else { \ |
| asprintf(&t, "echo \"%s:%d %s \">/proc/softap_assert", \ |
| __FUNCTION__, __LINE__, p); \ |
| system(t);\ |
| free(t);\ |
| asprintf(&p, "echo \"%s:%d %s \">/cache/net_last_asrt.txt", \ |
| __FUNCTION__, __LINE__, p); \ |
| system(p); \ |
| free(p); \ |
| } \ |
| assert(0); \ |
| }while(0) |
| #endif |
| #define softap_assert(fmt,...) do { \ |
| printf("%s:%d "fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ |
| assert(0); \ |
| }while(0) |
| |
| extern int slog_sysloglevel; |
| extern int slog_printlevel; |
| |
| /* |
| * ´òÓ¡½Ó¿Ú£¬ÒÔºó×ÔÑÐÄ£¿é´òÓ¡Ö»Ðèµ÷ÓÃ¸Ã½Ó¿Ú |
| * mod: ±êÇ©£¬ÓÃÓÚ¼ÓÉÏÄ£¿éÃû»ò×Ô¼ºÏ²°®µÄ×Ö·û´®×÷Ϊ±êÇ© |
| * prio: ´òÓ¡µÈ¼¶£¬¼´ºê: |
| * SLOG_DEBUG |
| * SLOG_ERR |
| * SLOG_NORMAL |
| * fmt¼°... : ¸ñʽ»¯×Ö·û´®, Õâ¸ö²¿·ÖÍêÈ«ºÍprintfµÄ²Î?Ò»Ö |
| */ |
| extern int slog(char *mod, int prio, const char *fmt, ...); |
| |
| void loglevel_init(void); |
| |
| void security_log(int mod,const char *fmt, ...); |
| |
| #endif |