log.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef _LOG_MYLOG_H_
  2. #define _LOG_MYLOG_H_
  3. #include<stdio.h>
  4. #include<string.h>
  5. #include<sys/socket.h>
  6. #include<arpa/inet.h>
  7. #include<stdlib.h>
  8. #include<getopt.h>
  9. #include <unistd.h>
  10. #include<errno.h>
  11. #include <fcntl.h>
  12. //#include"aes.h"
  13. #include <sys/epoll.h>
  14. #include <sys/wait.h>
  15. #include<map>
  16. #include<string>
  17. #include<vector>
  18. #include <sys/socket.h> //for socket ofcourse
  19. #include <sys/types.h>
  20. #include <stdlib.h> //for exit(0);
  21. #include <errno.h> //For errno - the error number
  22. #include <netinet/tcp.h> //Provides declarations for tcp header
  23. #include <netinet/udp.h>
  24. #include <netinet/ip.h> //Provides declarations for ip header
  25. #include <netinet/if_ether.h>
  26. #include <arpa/inet.h>
  27. #include <fcntl.h>
  28. #include <byteswap.h>
  29. #include <sys/socket.h>
  30. #include <sys/types.h>
  31. #include <arpa/inet.h>
  32. #include <linux/if_ether.h>
  33. #include <linux/filter.h>
  34. #include <sys/time.h>
  35. #include <time.h>
  36. #include <sys/timerfd.h>
  37. #include <set>
  38. //#include <encrypt.h>
  39. #include <inttypes.h>
  40. #include <sys/ioctl.h>
  41. #include <netinet/in.h>
  42. #include <net/if.h>
  43. #include <arpa/inet.h>
  44. #include <stdarg.h>
  45. using namespace std;
  46. #define RED "\x1B[31m"
  47. #define GRN "\x1B[32m"
  48. #define YEL "\x1B[33m"
  49. #define BLU "\x1B[34m"
  50. #define MAG "\x1B[35m"
  51. #define CYN "\x1B[36m"
  52. #define WHT "\x1B[37m"
  53. #define RESET "\x1B[0m"
  54. const int log_never=0;
  55. const int log_fatal=1;
  56. const int log_error=2;
  57. const int log_warn=3;
  58. const int log_info=4;
  59. const int log_debug=5;
  60. const int log_trace=6;
  61. const int log_end=7;
  62. const char log_text[][20]={"NEVER","FATAL","ERROR","WARN","INFO","DEBUG","TRACE",""};
  63. const char log_color[][20]={RED,RED,RED,YEL,GRN,MAG,""};
  64. extern int log_level;
  65. extern int enable_log_position;
  66. extern int enable_log_color;
  67. #ifdef MY_DEBUG
  68. #define mylog(__first_argu__dummy_abcde__,...) printf(__VA_ARGS__)
  69. #else
  70. #define mylog(...) log0(__FILE__,__FUNCTION__,__LINE__,__VA_ARGS__)
  71. #endif
  72. //#define mylog(__first_argu__dummy_abcde__,...) {;}
  73. void log0(const char * file,const char * function,int line,int level,const char* str, ...);
  74. void log_bare(int level,const char* str, ...);
  75. #endif