mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 06:19:31 +08:00
added log.h log.cpp
This commit is contained in:
parent
df58e3f914
commit
3e50007667
33
log.cpp
Executable file
33
log.cpp
Executable file
@ -0,0 +1,33 @@
|
||||
#include <log.h>
|
||||
|
||||
const int log_level=log_debug;
|
||||
|
||||
char log_text[][10]={"FATAL","ERROR","WARN","INFO","DEBUG","TRACE"};
|
||||
char log_color[][10]={RED,RED,YEL,GRN,BLU,""};
|
||||
void log(int level,const char* str, ...) {
|
||||
|
||||
if(level>log_level) return ;
|
||||
if(level>log_trace||level<0) return ;
|
||||
|
||||
|
||||
time_t timer;
|
||||
char buffer[100];
|
||||
struct tm* tm_info;
|
||||
|
||||
time(&timer);
|
||||
tm_info = localtime(&timer);
|
||||
|
||||
printf(log_color[level]);
|
||||
|
||||
strftime(buffer, 100, "%Y-%m-%d %H:%M:%S", tm_info);
|
||||
printf("[%s][%s]",buffer,log_text[level]);
|
||||
|
||||
|
||||
va_list vlist;
|
||||
va_start(vlist, str);
|
||||
vfprintf(stdout, str, vlist);
|
||||
va_end(vlist);
|
||||
printf(RESET);
|
||||
//printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
81
log.h
Executable file
81
log.h
Executable file
@ -0,0 +1,81 @@
|
||||
|
||||
#ifndef _LOG_MYLOG_H_
|
||||
#define _LOG_MYLOG_H_
|
||||
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#include<sys/socket.h>
|
||||
#include<arpa/inet.h>
|
||||
#include<stdlib.h>
|
||||
#include<getopt.h>
|
||||
#include <unistd.h>
|
||||
#include<errno.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
//#include"aes.h"
|
||||
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include<map>
|
||||
#include<string>
|
||||
#include<vector>
|
||||
|
||||
|
||||
#include <sys/socket.h> //for socket ofcourse
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h> //for exit(0);
|
||||
#include <errno.h> //For errno - the error number
|
||||
#include <netinet/tcp.h> //Provides declarations for tcp header
|
||||
#include <netinet/udp.h>
|
||||
#include <netinet/ip.h> //Provides declarations for ip header
|
||||
#include <netinet/if_ether.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <byteswap.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/filter.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <sys/timerfd.h>
|
||||
#include <set>
|
||||
#include <encrypt.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define RED "\x1B[31m"
|
||||
#define GRN "\x1B[32m"
|
||||
#define YEL "\x1B[33m"
|
||||
#define BLU "\x1B[34m"
|
||||
#define MAG "\x1B[35m"
|
||||
#define CYN "\x1B[36m"
|
||||
#define WHT "\x1B[37m"
|
||||
#define RESET "\x1B[0m"
|
||||
|
||||
const int log_fatal=0;
|
||||
const int log_error=1;
|
||||
const int log_warn=2;
|
||||
const int log_info=3;
|
||||
const int log_debug=4;
|
||||
const int log_trace=5;
|
||||
|
||||
|
||||
|
||||
|
||||
void log(int level,const char* str, ...);
|
||||
|
||||
|
||||
#endif
|
4
makefile
4
makefile
@ -2,7 +2,7 @@ ccmips=mips-openwrt-linux-g++
|
||||
all:
|
||||
killall raw||true
|
||||
sleep 1
|
||||
g++ main.cpp -o raw -static -lrt -ggdb -I. aes.c md5.c encrypt.cpp -O3
|
||||
${ccmips} -O3 main.cpp -o rawmips -lrt -I. aes.c md5.c encrypt.cpp
|
||||
g++ main.cpp -o raw -static -lrt -ggdb -I. aes.c md5.c encrypt.cpp log.cpp -O3
|
||||
${ccmips} -O3 main.cpp -o rawmips -lrt -I. aes.c md5.c encrypt.cpp log.cpp
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user