8 #include <boost/thread/mutex.hpp>
25 boost::atomic<int64_t> _current_file_number;
26 const int64_t _interval_seconds;
30 impl(
const config& c) :
cfg( c ), _interval_seconds(
cfg.rotation_interval.to_seconds() )
69 if( now < _next_file_time )
return;
73 _current_file_number.store( new_file_number );
76 int64_t prev_file_number = _current_file_number.load();
77 if( prev_file_number >= new_file_number )
return;
78 if( !_current_file_number.compare_exchange_weak( prev_file_number, new_file_number ) )
return;
81 _next_file_time = start_time + _interval_seconds;
95 out.
open( log_filename, std::ios_base::out | std::ios_base::app );
103 auto current_file = _current_file_number.load();
114 string current_filename = itr->filename().string();
115 if( current_filename.compare(0, link_filename_string.size(), link_filename_string) != 0
116 || current_filename.size() <= link_filename_string.size() + 1 )
118 string current_timestamp_str = current_filename.substr(link_filename_string.size() + 1,
119 timestamp_string.size());
121 if( current_timestamp < start_time
122 && ( current_timestamp < limit_time ||
file_size( current_filename ) <= 0 ) )
128 catch (
const fc::canceled_exception&)
144 format(
"${timestamp} ${thread_name} ${context} ${file}:${line} ${method} ${level}] ${message}" ),
161 std::stringstream line;
167 if( method_name.size() )
170 for( uint32_t i = 0;i < method_name.size(); ++i )
172 if( method_name[i] ==
':' ) p = i;
175 if( method_name[p] ==
':' )
182 line << message.c_str();