mirror of https://github.com/oxen-io/lokinet
refactor logging to use std::source_location
* 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 eLogNonepull/1638/head
parent
e32f7faf55
commit
5c457ff486
@ -1,24 +0,0 @@
|
||||
#include "json_logger.hpp"
|
||||
#include <llarp/util/json.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
void
|
||||
JSONLogStream::AppendLog(
|
||||
LogLevel lvl,
|
||||
const char* fname,
|
||||
int lineno,
|
||||
const std::string& nodename,
|
||||
const std::string msg)
|
||||
{
|
||||
json::Object obj;
|
||||
obj["time"] = to_json(llarp::time_now_ms());
|
||||
obj["nickname"] = nodename;
|
||||
obj["file"] = std::string(fname);
|
||||
obj["line"] = lineno;
|
||||
obj["level"] = LogLevelToString(lvl);
|
||||
obj["message"] = msg;
|
||||
m_Lines.pushBack(obj.dump());
|
||||
}
|
||||
|
||||
} // namespace llarp
|
@ -1,28 +0,0 @@
|
||||
#ifndef LLARP_UTIL_JSON_LOGGER
|
||||
#define LLARP_UTIL_JSON_LOGGER
|
||||
|
||||
#include "file_logger.hpp"
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
struct JSONLogStream : public FileLogStream
|
||||
{
|
||||
JSONLogStream(
|
||||
std::function<void(FileLogStream::Work_t)> disk,
|
||||
FILE* f,
|
||||
llarp_time_t flushInterval,
|
||||
bool closeFile)
|
||||
: FileLogStream(std::move(disk), f, flushInterval, closeFile)
|
||||
{}
|
||||
|
||||
void
|
||||
AppendLog(
|
||||
LogLevel lvl,
|
||||
const char* fname,
|
||||
int lineno,
|
||||
const std::string& nodename,
|
||||
const std::string msg) override;
|
||||
};
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cpp_lib_source_location
|
||||
#include <source_location>
|
||||
namespace slns = std;
|
||||
#else
|
||||
#include <experimental/source_location>
|
||||
namespace slns = std::experimental;
|
||||
#endif
|
Loading…
Reference in New Issue