lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #ifndef _SOFTAP_LOG_H_ |
| 2 | #define _SOFTAP_LOG_H_ |
| 3 | #define _POSIX_C_SOURCE 199309 |
| 4 | #include <stdio.h> |
| 5 | #include <string.h> |
| 6 | #include <signal.h> |
| 7 | #include <sys/types.h> |
| 8 | #include <unistd.h> |
| 9 | #include <stdlib.h> |
| 10 | #include <stdarg.h> |
| 11 | #include "cfg_api.h" |
| 12 | |
| 13 | #define SIG_LOGLEV (SIGRTMIN + 1) |
| 14 | |
| 15 | #define LOG_OFF 0 |
| 16 | #define LOG_ON 0xff |
| 17 | |
| 18 | /* |
| 19 | * ´òÓ¡µÈ¼¶ |
| 20 | */ |
| 21 | #define SLOG_DEBUG 1 //Ñз¢¸öÌåÐÐΪlogÊä³ö£¬Á¿ºÜ´ó |
| 22 | #define SLOG_NORMAL 2 //¼¯³É²âÊÔ½×¶ÎlogÊä³ö£¬Á¿ÊÊÖÐ |
| 23 | #define SLOG_ERR 3 //ÖÂÃü»ò¿ìÕÕÀàlogÊä³ö£¬Á¿Ð¡ |
| 24 | #define SLOG_OFF 4 //È«²¿¹Ø±Õ´òÓ¡ |
| 25 | |
| 26 | #define SLOG_SOCTIME_OFF 0 |
| 27 | #define SLOG_SOCTIME_ON 1 |
| 28 | |
| 29 | #define NET_PRINT "[net]" |
| 30 | #define AT_PRINT "[at]" |
| 31 | #define MMI_PRINT "[mmi]" |
| 32 | #define MISC_PRINT "[misc]" |
| 33 | #define SDCARD_PRINT "[sdcard]" |
| 34 | #define USBCFGMNG_PRINT "[usbcfgmng]" |
| 35 | #define FLUXSTAT_PRINT "[fluxstat]" |
| 36 | #define WIFI_PRINT "[wifi]" |
| 37 | #define RTC_PRINT "[rtc]" |
| 38 | #define TR069_PRINT "[tr069]" |
| 39 | #define PB_PRINT "[pb]" |
| 40 | #define SMS_PRINT "[sms]" |
| 41 | #define MISC_MBIM "[mbim]" |
| 42 | #define DRVCOMMNG_PRINT "[drvcommng]" |
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 43 | #define ABSVR_PRINT "[absvr]" |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 44 | |
| 45 | extern int asprintf(char **strp, const char *fmt, ...); |
| 46 | |
| 47 | /** |
| 48 | * @brief ͳһ¶ÏÑÔËÀ»ú½Ó¿Ú£¬½«ËÀ»úÔÒòechoµ½ÄÚºËsoftap_assert½ÚµãÖУ¬¶ÔÓ¦Äں˵ÄassertÈ«¾Ö±äÁ¿ÖÐ |
| 49 | */ |
| 50 | #if 0//klocwork |
| 51 | #define softap_assert(...) do { \ |
| 52 | char *p,*t; \ |
| 53 | if (-1 == asprintf(&p, __VA_ARGS__)) { \ |
| 54 | char tmp[128] = {0}; \ |
| 55 | sprintf(tmp,"echo \"%s:%d \">/proc/softap_assert", \ |
| 56 | __FUNCTION__, __LINE__); \ |
| 57 | system(tmp); \ |
| 58 | bzero(tmp, 128); \ |
| 59 | sprintf(tmp,"echo \"%s:%d \">/cache/net_last_asrt.txt", \ |
| 60 | __FUNCTION__, __LINE__); \ |
| 61 | system(tmp); \ |
| 62 | }else { \ |
| 63 | asprintf(&t, "echo \"%s:%d %s \">/proc/softap_assert", \ |
| 64 | __FUNCTION__, __LINE__, p); \ |
| 65 | system(t);\ |
| 66 | free(t);\ |
| 67 | asprintf(&p, "echo \"%s:%d %s \">/cache/net_last_asrt.txt", \ |
| 68 | __FUNCTION__, __LINE__, p); \ |
| 69 | system(p); \ |
| 70 | free(p); \ |
| 71 | } \ |
| 72 | assert(0); \ |
| 73 | }while(0) |
| 74 | #endif |
| 75 | #define softap_assert(fmt,...) do { \ |
| 76 | printf("%s:%d "fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ |
| 77 | assert(0); \ |
| 78 | }while(0) |
| 79 | |
| 80 | extern int slog_sysloglevel; |
| 81 | extern int slog_printlevel; |
| 82 | |
| 83 | /* |
| 84 | * ´òÓ¡½Ó¿Ú£¬ÒÔºó×ÔÑÐÄ£¿é´òÓ¡Ö»Ðèµ÷ÓÃ¸Ã½Ó¿Ú |
| 85 | * mod: ±êÇ©£¬ÓÃÓÚ¼ÓÉÏÄ£¿éÃû»ò×Ô¼ºÏ²°®µÄ×Ö·û´®×÷Ϊ±êÇ© |
| 86 | * prio: ´òÓ¡µÈ¼¶£¬¼´ºê: |
| 87 | * SLOG_DEBUG |
| 88 | * SLOG_ERR |
| 89 | * SLOG_NORMAL |
| 90 | * fmt¼°... : ¸ñʽ»¯×Ö·û´®, Õâ¸ö²¿·ÖÍêÈ«ºÍprintfµÄ²Î?Ò»Ö |
| 91 | */ |
| 92 | extern int slog(char *mod, int prio, const char *fmt, ...); |
| 93 | |
| 94 | void loglevel_init(void); |
| 95 | |
| 96 | void security_log(int mod,const char *fmt, ...); |
| 97 | |
| 98 | #endif |