2
* Copyright © 2013 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3,
6
* as published by the Free Software Foundation.
8
* This program 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.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Alan Griffiths <alan@octopull.co.uk>
19
#include "mir/logging/input_report.h"
20
#include "mir/logging/logger.h"
22
#include "std/MirLog.h"
27
namespace ml = mir::logging;
28
namespace mli = mir::logging::input_report;
32
char const* const component = "android-input";
37
std::shared_ptr<MyInputReport> the_input_report;
42
MyInputReport(std::shared_ptr<ml::Logger> const& logger) :
47
void log(int prio, char const* buffer)
51
case ANDROID_LOG_UNKNOWN:
52
case ANDROID_LOG_DEFAULT:
53
case ANDROID_LOG_VERBOSE:
54
case ANDROID_LOG_DEBUG:
55
logger->log<ml::Logger::debug>(buffer, component);
58
case ANDROID_LOG_INFO:
59
logger->log<ml::Logger::informational>(buffer, component);
62
case ANDROID_LOG_WARN:
63
logger->log<ml::Logger::warning>(buffer, component);
66
case ANDROID_LOG_ERROR:
67
logger->log<ml::Logger::error>(buffer, component);
72
std::shared_ptr<ml::Logger> const logger;
75
void my_write_to_log(int prio, char const* buffer)
77
std::unique_lock<std::mutex> lock(mutex);
78
the_input_report->log(prio, buffer);
83
void mli::initialize(std::shared_ptr<Logger> const& logger)
85
std::unique_lock<std::mutex> lock(mutex);
86
::the_input_report = std::make_shared<MyInputReport>(logger);
88
mir::write_to_log = my_write_to_log;