a bunch of commit together,i lost some commit log while upgrading git

This commit is contained in:
wangyu
2017-07-26 06:29:40 +08:00
committed by wangyu
parent c6371c0ef5
commit 93c0d789c4
6 changed files with 591 additions and 345 deletions

26
log.cpp
View File

@@ -1,10 +1,10 @@
#include <log.h>
int log_level=log_impossible;
int log_level=log_info;
int enable_log_position=1;
int enable_log_color=1;
char log_text[][20]={"IMPOSSIBLE","FATAL","ERROR","WARN","INFO","DEBUG","TRACE"};
char log_text[][20]={"NEVER","FATAL","ERROR","WARN","INFO","DEBUG","TRACE",""};
char log_color[][20]={RED,RED,RED,YEL,GRN,BLU,""};
void log0(const char * file,const char * function,int line,int level,const char* str, ...) {
@@ -20,7 +20,7 @@ void log0(const char * file,const char * function,int line,int level,const char*
tm_info = localtime(&timer);
if(enable_log_color)
printf(log_color[level]);
printf(log_color[level]);
strftime(buffer, 100, "%Y-%m-%d %H:%M:%S", tm_info);
printf("[%s][%s]",buffer,log_text[level],file,line);
@@ -33,6 +33,26 @@ void log0(const char * file,const char * function,int line,int level,const char*
va_end(vlist);
if(enable_log_color)
printf(RESET);
//printf("\n");
if(enable_log_color)
printf(log_color[level]);
fflush(stdout);
}
void log_bare(int level,const char* str, ...)
{
if(level>log_level) return ;
if(level>log_trace||level<0) return ;
if(enable_log_color)
printf(log_color[level]);
va_list vlist;
va_start(vlist, str);
vfprintf(stdout, str, vlist);
va_end(vlist);
if(enable_log_color)
printf(RESET);
fflush(stdout);
}