lokinet/llarp/util/logging/android_logger.cpp
Thomas Winget 7caa87862e standardize include format and pragma once
All #ifndef guards on headers have been removed, I think,
in favor of #pragma once

Headers are now included as `#include "filename"` if the included file
resides in the same directory as the file including it, or any
subdirectory therein.  Otherwise they are included as
`#include <project/top/dir/relative/path/filename>`

The above does not include system/os headers.
2021-03-09 19:01:41 -05:00

70 lines
1.5 KiB
C++

#if defined(ANDROID)
#include "android_logger.hpp"
#include "logger_internal.hpp"
#include <android/log.h>
namespace llarp
{
void
AndroidLogStream::PreLog(
std::stringstream& ss, LogLevel lvl, const char* fname, int lineno, const std::string&) const
{
switch (lvl)
{
case eLogNone:
return;
case eLogTrace:
ss << "[TRC] ";
break;
case eLogDebug:
ss << "[DBG] ";
break;
case eLogInfo:
ss << "[NFO] ";
break;
case eLogWarn:
ss << "[WRN] ";
break;
case eLogError:
ss << "[ERR] ";
break;
}
ss << "(" << thread_id_string() << ") " << log_timestamp() << " " << fname << ":" << lineno
<< "\t";
}
void
AndroidLogStream::PostLog(std::stringstream&) const
{}
void AndroidLogStream::Tick(llarp_time_t)
{}
void
AndroidLogStream::Print(LogLevel lvl, const char* tag, const std::string& msg)
{
std::string str("lokinet|");
str += tag;
switch (lvl)
{
case eLogTrace:
case eLogDebug:
__android_log_write(ANDROID_LOG_DEBUG, str.c_str(), msg.c_str());
return;
case eLogInfo:
__android_log_write(ANDROID_LOG_INFO, str.c_str(), msg.c_str());
return;
case eLogWarn:
__android_log_write(ANDROID_LOG_WARN, str.c_str(), msg.c_str());
return;
case eLogError:
__android_log_write(ANDROID_LOG_ERROR, str.c_str(), msg.c_str());
return;
}
} // namespace llarp
} // namespace llarp
#endif