mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-10-31 09:20:21 +00:00
5c457ff486
* use std::source_location instead of godawful macros in logging * remove unused/absolutely haram af json logstream * fix bug in android logger where it doesn't respect eLogNone
73 lines
1.6 KiB
C++
73 lines
1.6 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, std::string_view 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, std::string_view 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;
|
|
default:
|
|
return;
|
|
}
|
|
|
|
} // namespace llarp
|
|
} // namespace llarp
|
|
#endif
|