foobar2000 SDK  2015-08-03
event_logger.h
Go to the documentation of this file.
1 class NOVTABLE event_logger : public service_base {
2  FB2K_MAKE_SERVICE_INTERFACE(event_logger, service_base);
3 public:
4  enum {
7  severity_error
8  };
9  void log_status(const char * line) {log_entry(line, severity_status);}
10  void log_warning(const char * line) {log_entry(line, severity_warning);}
11  void log_error(const char * line) {log_entry(line, severity_error);}
12 
13  virtual void log_entry(const char * line, unsigned severity) = 0;
14 };
15 
17 public:
18  void log_entry(const char * line, unsigned) {console::print(line);}
19 };
20 
21 class NOVTABLE event_logger_recorder : public event_logger {
22  FB2K_MAKE_SERVICE_INTERFACE( event_logger_recorder , event_logger );
23 public:
24  virtual void playback( event_logger::ptr playTo ) = 0;
25 };
26 
28 public:
29  void playback( event_logger::ptr playTo ) {
30  for(auto i = m_entries.first(); i.is_valid(); ++i ) {
31  playTo->log_entry( i->line.get_ptr(), i->severity );
32  }
33  }
34 
35  void log_entry( const char * line, unsigned severity ) {
36  auto rec = m_entries.insert_last();
37  rec->line = line;
38  rec->severity = severity;
39  }
40 private:
41 
42  struct entry_t {
44  unsigned severity;
45  };
47 };
void log_entry(const char *line, unsigned)
Definition: event_logger.h:18
void playback(event_logger::ptr playTo)
Definition: event_logger.h:29
pfc::chain_list_v2_t< entry_t > m_entries
Definition: event_logger.h:46
Differences between chain_list_v2_t<> and old chain_list_t<>: Iterators pointing to removed items as...
Definition: chain_list_v2.h:26
void log_warning(const char *line)
Definition: event_logger.h:10
void log_error(const char *line)
Definition: event_logger.h:11
string_simple_t< char > string_simple
Definition: string_base.h:826
void log_entry(const char *line, unsigned severity)
Definition: event_logger.h:35
void log_status(const char *line)
Definition: event_logger.h:9
void print(const char *)
Definition: console.cpp:28
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333