GeNN  4.0.0
GPU enhanced Neuronal Networks (GeNN)
AndroidAppender.h
Go to the documentation of this file.
1 #pragma once
3 #include <android/log.h>
4 
5 namespace plog
6 {
7  template<class Formatter>
8  class AndroidAppender : public IAppender
9  {
10  public:
11  AndroidAppender(const char* tag) : m_tag(tag)
12  {
13  }
14 
15  virtual void write(const Record& record)
16  {
17  std::string str = Formatter::format(record);
18 
19  __android_log_print(toPriority(record.getSeverity()), m_tag, "%s", str.c_str());
20  }
21 
22  private:
23  static android_LogPriority toPriority(Severity severity)
24  {
25  switch (severity)
26  {
27  case fatal:
28  return ANDROID_LOG_FATAL;
29  case error:
30  return ANDROID_LOG_ERROR;
31  case warning:
32  return ANDROID_LOG_WARN;
33  case info:
34  return ANDROID_LOG_INFO;
35  case debug:
36  return ANDROID_LOG_DEBUG;
37  case verbose:
38  return ANDROID_LOG_VERBOSE;
39  default:
40  return ANDROID_LOG_UNKNOWN;
41  }
42  }
43 
44  private:
45  const char* const m_tag;
46  };
47 }
Definition: AndroidAppender.h:5
Definition: Severity.h:11
AndroidAppender(const char *tag)
Definition: AndroidAppender.h:11
Definition: Severity.h:13
Definition: Severity.h:9
Definition: AndroidAppender.h:8
virtual void write(const Record &record)
Definition: AndroidAppender.h:15
Definition: Severity.h:12
Definition: Severity.h:8
virtual Severity getSeverity() const
Definition: Record.h:185
Definition: Record.h:102
Definition: IAppender.h:6
Definition: Severity.h:10
Severity
Definition: Severity.h:5