20 #include <boost/algorithm/string.hpp> 31 log_level_t::log_level_t(
int v,
const std::string& s)
63 log_t::write(
const std::string& file,
65 const std::string&
function,
67 const std::string& message)
84 std::vector<std::string> dirs;
85 boost::split(dirs, file, boost::is_any_of(
"/"));
103 logger().write(m_file, m_line, m_function, m_level, m_stream.str());
115 auto end = std::chrono::system_clock::now();
116 auto end_time = std::chrono::system_clock::to_time_t(
end);
122 std::string display = std::ctime(&end_time);
130 m_file_stream.open(ofile);
135 m_file_stream.close();
141 const std::string&
function,
143 const std::string& message)
146 m_file_stream <<
" [" << level.
to_string() <<
"]" << file <<
":" << line
147 <<
" " <<
function <<
"() " << message << std::endl;
153 const std::string&
function,
155 const std::string& message)
158 std::cout <<
" [" << level.
to_string() <<
"]" << file <<
":" << line <<
" " 159 <<
function <<
"() " << message << std::endl;
entry(const char *file, const char *function, int line, const log_level_t &level)
virtual void handle_message(const std::string &file, const int line, const std::string &function, const log_level_t &level, const std::string &message)
Handle a log message.
virtual void handle_message(const std::string &file, const int line, const std::string &function, const log_level_t &level, const std::string &message)
Handle a log message.
static std::string get_filename(const std::string &file)
virtual void handle_message(const std::string &file, const int line, const std::string &function, const log_level_t &level, const std::string &message)=0
Handle a log message.
static const log_level_t DEBUG
const log_level_t & level() const
The configured level.
std::stringstream & stream()
static const log_level_t CRITICAL
vl_api_cnat_endpoint_t new
static const log_level_t WARNING
static const log_level_t INFO
Ideally we'd use the boost logger but that is not prevelent in many distros.
const std::string & to_string() const
convert to string format for debug purposes
static std::string get_timestamp()
void set(const log_level_t &level)
set the logging level
static const log_level_t ERROR
The VPP Object Model (VOM) library.
log_t & logger()
Return a log object into which VPP objects can write.
f64 end
end of the time range
file_handler(const std::string &ofile)