ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/CommonLibs/plog/Appenders/AndroidAppender.h
(Generate patch)

Comparing s10k/CommonLibs/plog/Appenders/AndroidAppender.h (file contents):
Revision 1095 by s10k, Thu Oct 5 17:48:32 2017 UTC vs.
Revision 1096 by s10k, Sat Dec 30 14:40:33 2017 UTC

# Line 1 | Line 1
1 < #pragma once
2 < #include <plog/Appenders/IAppender.h>
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 < }
1 > #pragma once
2 > #include <plog/Appenders/IAppender.h>
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 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)