log.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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_impossible=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. extern int log_level;
  62. #define log(...) log0(__FILE__,__FUNCTION__,__LINE__,__VA_ARGS__)
  63. void log0(const char * file,const char * function,int line,int level,const char* str, ...);
  64. #endif