log_parser.h
Go to the documentation of this file.
1 // Splits the log stream into individual messages
2 // Author: Max Schwarz <max.schwarz@ais.uni-bonn.de>
3 
4 #ifndef ROSMON_MONITOR_LOG_PARSER_H
5 #define ROSMON_MONITOR_LOG_PARSER_H
6 
7 #include <chrono>
8 #include <memory>
9 #include <functional>
10 
11 #include "../log_event.h"
12 
13 namespace rosmon
14 {
15 namespace monitor
16 {
17 
18 class LogParser
19 {
20 public:
21  LogParser();
22  ~LogParser();
23 
24  struct Event
25  {
26  std::string message;
28  };
29 
30  void setCallback(const std::function<void(Event&&)>& cb);
31 
32  void process(const char* input, std::size_t size, const std::chrono::steady_clock::time_point& time = std::chrono::steady_clock::now());
33 
34  inline void processString(const std::string& str, const std::chrono::steady_clock::time_point& time = std::chrono::steady_clock::now())
35  { process(str.c_str(), str.length(), time); }
36 
37  void checkPending(const std::chrono::steady_clock::time_point& time = std::chrono::steady_clock::now());
38 
39  void flush();
40 
41 private:
42  class Private;
43  std::unique_ptr<Private> m_d;
44 };
45 
46 }
47 }
48 
49 
50 #endif
rosmon
Definition: diagnostics_publisher.cpp:34
rosmon::monitor::LogParser::setCallback
void setCallback(const std::function< void(Event &&)> &cb)
Definition: log_parser.cpp:213
rosmon::monitor::LogParser::processString
void processString(const std::string &str, const std::chrono::steady_clock::time_point &time=std::chrono::steady_clock::now())
Definition: log_parser.h:34
rosmon::monitor::LogParser::LogParser
LogParser()
Definition: log_parser.cpp:198
rosmon::monitor::LogParser::flush
void flush()
Definition: log_parser.cpp:223
rosmon::LogEvent::Type
Type
Definition: log_event.h:16
rosmon::monitor::LogParser::Event::severity
LogEvent::Type severity
Definition: log_parser.h:27
rosmon::monitor::LogParser::~LogParser
~LogParser()
Definition: log_parser.cpp:203
rosmon::monitor::LogParser::m_d
std::unique_ptr< Private > m_d
Definition: log_parser.h:42
rosmon::monitor::LogParser::Event::message
std::string message
Definition: log_parser.h:26
rosmon::monitor::LogParser::checkPending
void checkPending(const std::chrono::steady_clock::time_point &time=std::chrono::steady_clock::now())
Definition: log_parser.cpp:218
rosmon::monitor::LogParser::Private
Definition: log_parser.cpp:15
rosmon::monitor::LogParser::process
void process(const char *input, std::size_t size, const std::chrono::steady_clock::time_point &time=std::chrono::steady_clock::now())
Definition: log_parser.cpp:207
rosmon::monitor::LogParser
Definition: log_parser.h:18
rosmon::monitor::LogParser::Event
Definition: log_parser.h:24


rosmon_core
Author(s): Max Schwarz
autogenerated on Wed Feb 21 2024 04:01:14