@ -15,12 +15,18 @@
namespace rocksdb {
namespace rocksdb {
EventLoggerStream : : EventLoggerStream ( Logger * logger )
EventLoggerStream : : EventLoggerStream ( Logger * logger )
: logger_ ( logger ) , log_buffer_ ( nullptr ) , json_writer_ ( nullptr ) { }
: logger_ ( logger ) ,
log_buffer_ ( nullptr ) ,
max_log_size_ ( 0 ) ,
json_writer_ ( nullptr ) { }
EventLoggerStream : : EventLoggerStream ( LogBuffer * log_buffer )
EventLoggerStream : : EventLoggerStream ( LogBuffer * log_buffer ,
: logger_ ( nullptr ) , log_buffer_ ( log_buffer ) , json_writer_ ( nullptr ) { }
const size_t max_log_size )
: logger_ ( nullptr ) ,
log_buffer_ ( log_buffer ) ,
max_log_size_ ( max_log_size ) ,
json_writer_ ( nullptr ) { }
EventLoggerStream : : ~ EventLoggerStream ( ) {
EventLoggerStream : : ~ EventLoggerStream ( ) {
if ( json_writer_ ) {
if ( json_writer_ ) {
@ -31,7 +37,8 @@ EventLoggerStream::~EventLoggerStream() {
if ( logger_ ) {
if ( logger_ ) {
EventLogger : : Log ( logger_ , * json_writer_ ) ;
EventLogger : : Log ( logger_ , * json_writer_ ) ;
} else if ( log_buffer_ ) {
} else if ( log_buffer_ ) {
EventLogger : : LogToBuffer ( log_buffer_ , * json_writer_ ) ;
assert ( max_log_size_ ) ;
EventLogger : : LogToBuffer ( log_buffer_ , * json_writer_ , max_log_size_ ) ;
}
}
# endif
# endif
delete json_writer_ ;
delete json_writer_ ;
@ -50,13 +57,14 @@ void EventLogger::Log(Logger* logger, const JSONWriter& jwriter) {
# endif
# endif
}
}
void EventLogger : : LogToBuffer (
void EventLogger : : LogToBuffer ( LogBuffer * log_buffer , const JSONWriter & jwriter ,
LogBuffer * log_buffer , const JSONWriter & jwriter ) {
const size_t max_log_size ) {
# ifdef ROCKSDB_PRINT_EVENTS_TO_STDOUT
# ifdef ROCKSDB_PRINT_EVENTS_TO_STDOUT
printf ( " %s \n " , jwriter . Get ( ) . c_str ( ) ) ;
printf ( " %s \n " , jwriter . Get ( ) . c_str ( ) ) ;
# else
# else
assert ( log_buffer ) ;
assert ( log_buffer ) ;
rocksdb : : LogToBuffer ( log_buffer , " %s %s " , Prefix ( ) , jwriter . Get ( ) . c_str ( ) ) ;
rocksdb : : LogToBuffer ( log_buffer , max_log_size , " %s %s " , Prefix ( ) ,
jwriter . Get ( ) . c_str ( ) ) ;
# endif
# endif
}
}