/** configure through script right now, you can only specify the file name */ void configure(const hold_string_type & str) { // configure - the file name, for now non_const_context_base::context().close(); non_const_context_base::context().name.assign( str.begin(), str.end() ); }
/** configure through script right now, you can only specify the file name prefix */ void configure(const hold_string_type & str) { // configure - the file prefix, for now non_const_context_base::context().m_name_prefix.assign( str.begin(), str.end()); non_const_context_base::context().m_cur_idx = 0; non_const_context_base::context().restart(); }
void set_format(const hold_string_type & format) { // format too big BOOST_ASSERT( format.size() < 64); m_format.clear(); m_day = -1; m_month = -1; m_yy = -1; m_yyyy = -1; m_hour = -1; m_min = -1; m_sec = -1;m_millisec = -1;m_microsec = -1;m_nanosec = -1; typedef hold_string_type::size_type uint; uint day_idx = format.find(BOOST_LOG_STR("$dd")); uint month_idx = format.find(BOOST_LOG_STR("$MM")); uint yy_idx = format.find(BOOST_LOG_STR("$yy")); uint yyyy_idx = format.find(BOOST_LOG_STR("$yyyy")); uint hour_idx = format.find(BOOST_LOG_STR("$hh")); uint min_idx = format.find(BOOST_LOG_STR("$mm")); uint sec_idx = format.find(BOOST_LOG_STR("$ss")); uint millisec_idx = format.find(BOOST_LOG_STR("$mili")); uint microsec_idx = format.find(BOOST_LOG_STR("$micro")); uint nanosec_idx = format.find(BOOST_LOG_STR("$nano")); typedef std::vector<index_info> array; array indexes; if ( day_idx != hold_string_type::npos) indexes.push_back( index_info(day_idx, &m_day) ); if ( month_idx != hold_string_type::npos) indexes.push_back( index_info(month_idx, &m_month) ); if ( yy_idx != hold_string_type::npos || yyyy_idx != hold_string_type::npos) { if ( yyyy_idx != hold_string_type::npos) indexes.push_back( index_info(yyyy_idx, &m_yyyy, 4) ); else indexes.push_back( index_info(yy_idx, &m_yy) ); } if ( hour_idx != hold_string_type::npos) indexes.push_back( index_info(hour_idx, &m_hour ) ); if ( min_idx != hold_string_type::npos) indexes.push_back( index_info(min_idx, &m_min) ); if ( sec_idx != hold_string_type::npos) indexes.push_back( index_info(sec_idx, &m_sec) ); if ( millisec_idx != hold_string_type::npos) indexes.push_back( index_info(millisec_idx, &m_millisec, 4, 3) ); if ( microsec_idx != hold_string_type::npos) indexes.push_back( index_info(microsec_idx, &m_microsec, 5, 6) ); if ( nanosec_idx != hold_string_type::npos) indexes.push_back( index_info(nanosec_idx, &m_nanosec, 4, 9) ); std::sort( indexes.begin(), indexes.end(), index_info::by_index); // create the format string, that we can actually pass to sprintf uint prev_idx = 0; int idx = 0; for ( array::iterator begin = indexes.begin(), end = indexes.end(); begin != end; ++begin) { m_format += format.substr( prev_idx, begin->src_idx - prev_idx); *begin->format_idx = idx; std::basic_ostringstream<char_type> cur_sprintf_format; cur_sprintf_format << BOOST_LOG_STR("%0") << begin->size << BOOST_LOG_STR("d"); m_format += cur_sprintf_format.str(); prev_idx = begin->src_idx + begin->advance_size + 1; ++idx; } m_format += format.substr(prev_idx); }