NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
logger-android.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013-2021 Regents of the University of California.
4
*
5
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6
*
7
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
8
* terms of the GNU Lesser General Public License as published by the Free Software
9
* Foundation, either version 3 of the License, or (at your option) any later version.
10
*
11
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14
*
15
* You should have received copies of the GNU General Public License and GNU Lesser
16
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17
* <http://www.gnu.org/licenses/>.
18
*
19
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20
*/
21
22
#include "
ndn-cxx/util/impl/logger-android.hpp
"
23
24
#include <boost/log/sinks.hpp>
25
26
#include <android/log.h>
27
28
namespace
ndn
{
29
namespace
util {
30
namespace
detail {
31
32
class
AndroidSinkBackend
:
public
boost::log::sinks::basic_sink_backend<boost::log::sinks::concurrent_feeding>
33
{
34
public
:
35
static
int
36
convertToAndroidSeverity
(
LogLevel
level
)
37
{
38
switch
(level) {
39
case
LogLevel::FATAL
:
40
return
ANDROID_LOG_FATAL;
41
case
LogLevel::ERROR
:
42
return
ANDROID_LOG_ERROR;
43
case
LogLevel::WARN
:
44
return
ANDROID_LOG_WARN;
45
case
LogLevel::INFO
:
46
return
ANDROID_LOG_INFO;
47
case
LogLevel::DEBUG
:
48
return
ANDROID_LOG_DEBUG;
49
case
LogLevel::TRACE
:
50
return
ANDROID_LOG_VERBOSE;
51
case
LogLevel::NONE
:
// not a real log level, but just for translation
52
return
ANDROID_LOG_SILENT;
53
case
LogLevel::ALL
:
54
return
ANDROID_LOG_VERBOSE;
// this is "ALL" for Android
55
}
56
}
57
58
void
59
consume
(
const
boost::log::record_view& rec)
60
{
61
auto
severity =
convertToAndroidSeverity
(rec[log::severity].
get
());
62
auto
module = rec[log::module].get();
63
auto
msg = rec[boost::log::expressions::smessage].get();
64
65
__android_log_write(severity, module.data(), msg.data());
66
}
67
};
68
69
boost::shared_ptr<boost::log::sinks::sink>
70
makeAndroidLogger
()
71
{
72
return
boost::make_shared<boost::log::sinks::synchronous_sink<AndroidSinkBackend>>();
73
}
74
75
}
// namespace detail
76
}
// namespace util
77
}
// namespace ndn
ndn::util::detail::AndroidSinkBackend
Definition:
logger-android.cpp:32
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::util::LogLevel::TRACE
trace messages (most verbose)
ndn::util::LogLevel::DEBUG
debug messages
ndn::util::LogLevel::ERROR
serious error messages
ndn::util::LogLevel::INFO
informational messages
logger-android.hpp
ndn::util::LogLevel
LogLevel
Indicates the severity level of a log message.
Definition:
logger.hpp:32
ndn::util::LogLevel::ALL
all messages
ndn::util::LogLevel::WARN
warning messages
ndn::util::detail::AndroidSinkBackend::consume
void consume(const boost::log::record_view &rec)
Definition:
logger-android.cpp:59
ndn::util::detail::AndroidSinkBackend::convertToAndroidSeverity
static int convertToAndroidSeverity(LogLevel level)
Definition:
logger-android.cpp:36
ndn::util::LogLevel::FATAL
fatal (will be logged unconditionally)
ndn::util::LogLevel::NONE
no messages
websocketpp::log::level
uint32_t level
Type of a channel package.
Definition:
levels.hpp:37
ndn::util::detail::makeAndroidLogger
boost::shared_ptr< boost::log::sinks::sink > makeAndroidLogger()
Definition:
logger-android.cpp:70
ndnSIM
ndn-cxx
ndn-cxx
util
impl
logger-android.cpp
Generated on Fri May 6 2022 12:34:13 for ndnSIM by
1.8.13