source: s10k/CommonLibs/plog/Appenders/AndroidAppender.h@ 1094

Last change on this file since 1094 was 1073, checked in by s10k, 7 years ago

added XML Tools latest version (2.0d) and s10k's common libs

File size: 1.2 KB
RevLine 
[1073]1#pragma once
2#include <plog/Appenders/IAppender.h>
3#include <android/log.h>
4
5namespace 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}
Note: See TracBrowser for help on using the repository browser.