2019-04-11 12:58:23 +00:00
|
|
|
#if defined(ANDROID)
|
2019-09-01 12:10:49 +00:00
|
|
|
|
|
|
|
#include <util/logging/android_logger.hpp>
|
|
|
|
#include <util/logging/logger_internal.hpp>
|
|
|
|
|
2019-04-11 12:58:23 +00:00
|
|
|
#include <android/log.h>
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
void
|
|
|
|
AndroidLogStream::PreLog(std::stringstream& ss, LogLevel lvl,
|
2019-07-24 15:25:40 +00:00
|
|
|
const char* fname, int lineno,
|
|
|
|
const std::string&) const
|
2019-04-11 12:58:23 +00:00
|
|
|
{
|
|
|
|
switch(lvl)
|
|
|
|
{
|
|
|
|
case eLogNone:
|
|
|
|
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
|
2019-07-24 14:17:54 +00:00
|
|
|
AndroidLogStream::PostLog(std::stringstream&) const
|
2019-04-11 12:58:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-07-24 15:25:40 +00:00
|
|
|
void AndroidLogStream::Tick(llarp_time_t)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-04-11 12:58:23 +00:00
|
|
|
void
|
2019-04-16 13:20:48 +00:00
|
|
|
AndroidLogStream::Print(LogLevel lvl, const char* tag, const std::string& msg)
|
2019-04-11 12:58:23 +00:00
|
|
|
{
|
|
|
|
std::string str("lokinet|");
|
|
|
|
str += tag;
|
|
|
|
switch(lvl)
|
|
|
|
{
|
|
|
|
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
|