1 #include <android/log.h>
2 #include <boost/log/core.hpp>
3 #include <boost/log/sinks.hpp>
5 namespace log = boost::log;
7 class android_log_sink :
public log::sinks::basic_sink_backend<log::sinks::synchronized_feeding> {
11 void consume(log::record_view
const& rec) {
12 const auto& rec_message_attr = rec[log::aux::default_attribute_names::message()];
13 int log_priority = android_LogPriority::ANDROID_LOG_VERBOSE +
14 rec[log::aux::default_attribute_names::severity()].extract_or_default(0);
15 __android_log_write(log_priority,
"aktualizr", rec_message_attr.extract_or_default(std::string(
"N/A")).c_str());
19 void logger_init_sink(
bool use_colors =
false) {
21 typedef log::sinks::synchronous_sink<android_log_sink> android_log_sink_t;
22 log::core::get()->add_sink(boost::shared_ptr<android_log_sink_t>(
new android_log_sink_t()));