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

Last change on this file was 1096, checked in by s10k, 7 years ago

Added zlib, quazip, basicxmlsyntaxhighlighter, conditionalsemaphore and linenumberdisplay libraries. zlib and quazip are pre-compiled, but you can compile them yourself, just delete the dll files (or equivalent binary files to your OS)

File size: 1.1 KB
RevLine 
[1096]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.