@ -95,15 +95,19 @@ void LogFlush(Logger *info_log) {
}
}
void Log ( Logger * info_log , const char * format , . . . ) {
static void Logv ( Logger * info_log , const char * format , va_list ap ) {
if ( info_log & & info_log - > GetInfoLogLevel ( ) < = InfoLogLevel : : INFO_LEVEL ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : INFO_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
}
void Log ( Logger * info_log , const char * format , . . . ) {
va_list ap ;
va_start ( ap , format ) ;
Logv ( info_log , format , ap ) ;
va_end ( ap ) ;
}
void Logger : : Logv ( const InfoLogLevel log_level , const char * format , va_list ap ) {
static const char * kInfoLogLevelNames [ 5 ] = { " DEBUG " , " INFO " , " WARN " ,
" ERROR " , " FATAL " } ;
@ -126,152 +130,161 @@ void Logger::Logv(const InfoLogLevel log_level, const char* format, va_list ap)
}
}
void Log ( const InfoLogLevel log_level , Logger * info_log , const char * format ,
. . . ) {
static void Logv ( const InfoLogLevel log_level , Logger * info_log , const char * format , va_list ap ) {
if ( info_log & & info_log - > GetInfoLogLevel ( ) < = log_level ) {
va_list ap ;
va_start ( ap , format ) ;
if ( log_level = = InfoLogLevel : : HEADER_LEVEL ) {
info_log - > LogHeader ( format , ap ) ;
} else {
info_log - > Logv ( log_level , format , ap ) ;
}
va_end ( ap ) ;
}
}
void Header ( Logger * info_log , const char * format , . . . ) {
void Log ( const InfoLogLevel log_level , Logger * info_log , const char * format ,
. . . ) {
va_list ap ;
va_start ( ap , format ) ;
Logv ( log_level , info_log , format , ap ) ;
va_end ( ap ) ;
}
static void Headerv ( Logger * info_log , const char * format , va_list ap ) {
if ( info_log ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > LogHeader ( format , ap ) ;
va_end ( ap ) ;
}
}
void Debug ( Logger * info_log , const char * format , . . . ) {
void Header ( Logger * info_log , const char * format , . . . ) {
va_list ap ;
va_start ( ap , format ) ;
Headerv ( info_log , format , ap ) ;
va_end ( ap ) ;
}
static void Debugv ( Logger * info_log , const char * format , va_list ap ) {
if ( info_log & & info_log - > GetInfoLogLevel ( ) < = InfoLogLevel : : DEBUG_LEVEL ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : DEBUG_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
}
void Info ( Logger * info_log , const char * format , . . . ) {
void Debug ( Logger * info_log , const char * format , . . . ) {
va_list ap ;
va_start ( ap , format ) ;
Debugv ( info_log , format , ap ) ;
va_end ( ap ) ;
}
static void Infov ( Logger * info_log , const char * format , va_list ap ) {
if ( info_log & & info_log - > GetInfoLogLevel ( ) < = InfoLogLevel : : INFO_LEVEL ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : INFO_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
}
void Warn ( Logger * info_log , const char * format , . . . ) {
void Info ( Logger * info_log , const char * format , . . . ) {
va_list ap ;
va_start ( ap , format ) ;
Infov ( info_log , format , ap ) ;
va_end ( ap ) ;
}
static void Warnv ( Logger * info_log , const char * format , va_list ap ) {
if ( info_log & & info_log - > GetInfoLogLevel ( ) < = InfoLogLevel : : WARN_LEVEL ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : WARN_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
}
void Error ( Logger * info_log , const char * format , . . . ) {
void Warn ( Logger * info_log , const char * format , . . . ) {
va_list ap ;
va_start ( ap , format ) ;
Warnv ( info_log , format , ap ) ;
va_end ( ap ) ;
}
static void Errorv ( Logger * info_log , const char * format , va_list ap ) {
if ( info_log & & info_log - > GetInfoLogLevel ( ) < = InfoLogLevel : : ERROR_LEVEL ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : ERROR_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
}
void Fatal ( Logger * info_log , const char * format , . . . ) {
void Error ( Logger * info_log , const char * format , . . . ) {
va_list ap ;
va_start ( ap , format ) ;
Errorv ( info_log , format , ap ) ;
va_end ( ap ) ;
}
static void Fatalv ( Logger * info_log , const char * format , va_list ap ) {
if ( info_log & & info_log - > GetInfoLogLevel ( ) < = InfoLogLevel : : FATAL_LEVEL ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : FATAL_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
}
void Fatal ( Logger * info_log , const char * format , . . . ) {
va_list ap ;
va_start ( ap , format ) ;
Fatalv ( info_log , format , ap ) ;
va_end ( ap ) ;
}
void LogFlush ( const shared_ptr < Logger > & info_log ) {
if ( info_log ) {
info_log - > Flush ( ) ;
}
LogFlush ( info_log . get ( ) ) ;
}
void Log ( const InfoLogLevel log_level , const shared_ptr < Logger > & info_log ,
const char * format , . . . ) {
if ( info_log ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( log_level , format , ap ) ;
va_end ( ap ) ;
}
va_list ap ;
va_start ( ap , format ) ;
Logv ( log_level , info_log . get ( ) , format , ap ) ;
va_end ( ap ) ;
}
void Header ( const shared_ptr < Logger > & info_log , const char * format , . . . ) {
if ( info_log ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > LogHeader ( format , ap ) ;
va_end ( ap ) ;
}
va_list ap ;
va_start ( ap , format ) ;
Headerv ( info_log . get ( ) , format , ap ) ;
va_end ( ap ) ;
}
void Debug ( const shared_ptr < Logger > & info_log , const char * format , . . . ) {
if ( info_log ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : DEBUG_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
va_list ap ;
va_start ( ap , format ) ;
Debugv ( info_log . get ( ) , format , ap ) ;
va_end ( ap ) ;
}
void Info ( const shared_ptr < Logger > & info_log , const char * format , . . . ) {
if ( info_log ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : INFO_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
va_list ap ;
va_start ( ap , format ) ;
Infov ( info_log . get ( ) , format , ap ) ;
va_end ( ap ) ;
}
void Warn ( const shared_ptr < Logger > & info_log , const char * format , . . . ) {
if ( info_log ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : WARN_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
va_list ap ;
va_start ( ap , format ) ;
Warnv ( info_log . get ( ) , format , ap ) ;
va_end ( ap ) ;
}
void Error ( const shared_ptr < Logger > & info_log , const char * format , . . . ) {
if ( info_log ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : ERROR_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
va_list ap ;
va_start ( ap , format ) ;
Errorv ( info_log . get ( ) , format , ap ) ;
va_end ( ap ) ;
}
void Fatal ( const shared_ptr < Logger > & info_log , const char * format , . . . ) {
if ( info_log ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : FATAL_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
va_list ap ;
va_start ( ap , format ) ;
Fatalv ( info_log . get ( ) , format , ap ) ;
va_end ( ap ) ;
}
void Log ( const shared_ptr < Logger > & info_log , const char * format , . . . ) {
if ( info_log ) {
va_list ap ;
va_start ( ap , format ) ;
info_log - > Logv ( InfoLogLevel : : INFO_LEVEL , format , ap ) ;
va_end ( ap ) ;
}
va_list ap ;
va_start ( ap , format ) ;
Logv ( info_log . get ( ) , format , ap ) ;
va_end ( ap ) ;
}
Status WriteStringToFile ( Env * env , const Slice & data , const std : : string & fname ,