blob: 324607a35131af8c28d6e9096640f4935a8a3597 [file] [log] [blame]
Steve Kondik2b563712017-06-19 23:14:18 -07001/* Copyright (C) 2015 TigerVNC
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19// -=- Logger_android.cxx - Logger instance for Android's logd
20
21#include <stdlib.h>
22#include <string.h>
23
24#include <utils/Log.h>
25
26#include <rfb/util.h>
27#include <rfb/Logger_android.h>
28#include <rfb/LogWriter.h>
29
30using namespace rfb;
31
32
33Logger_Android::Logger_Android(const char* loggerName)
34 : Logger(loggerName)
35{
36}
37
38Logger_Android::~Logger_Android()
39{
40}
41
42void Logger_Android::write(int level, const char *logname, const char *message)
43{
44 // Convert our priority level into Android log level
45 if (level >= LogWriter::LEVEL_DEBUG) {
46 ALOGD("%s: %s", logname, message);
47 } else if (level >= LogWriter::LEVEL_INFO) {
48 ALOGI("%s: %s", logname, message);
49 } else if (level >= LogWriter::LEVEL_STATUS) {
50 ALOGW("%s: %s", logname, message);
51 } else {
52 ALOGE("%s: %s", logname, message);
53 }
54}
55
56static Logger_Android logger("android");
57
58void rfb::initAndroidLogger() {
59 logger.registerLogger();
60}