update logging to use human readable time

pull/23/head
Jeff 6 years ago
parent 291cc57395
commit a1d1518bc0

@ -29,7 +29,7 @@ namespace llarp
bool
operator<(const RCNode& other) const
{
return rc.OtherIsNewer(other.rc);
return rc.last_updated < other.rc.last_updated;
}
};
@ -53,7 +53,7 @@ namespace llarp
bool
operator<(const ISNode& other) const
{
return introset.OtherIsNewer(other.introset);
return introset.T < other.introset.T;
}
};
} // namespace dht

@ -8,6 +8,7 @@
#include <llarp/ev.h>
#include <llarp/link/session.hpp>
#include <llarp/logic.h>
#include <llarp/time.h>
#include <list>
struct llarp_router;

@ -4,6 +4,7 @@
#include <llarp/crypto.hpp>
#include <llarp/net.hpp>
#include <llarp/router_contact.hpp>
#include <llarp/types.h>
#include <functional>
namespace llarp

@ -1,6 +1,6 @@
#ifndef LLARP_LOGGER_HPP
#define LLARP_LOGGER_HPP
#include <llarp/time.h>
#include <llarp/time.hpp>
#include <ctime>
#include <iomanip>
#include <iostream>
@ -79,6 +79,17 @@ namespace llarp
return std::to_string(id);
}
struct log_timestamp
{
std::string format = "%c %Z";
friend
std::ostream & operator << (std::ostream & out, const log_timestamp & ts)
{
auto now = llarp::Clock_t::to_time_t(llarp::Clock_t::now());
return out << std::put_time(std::localtime(&now), ts.format.c_str());
}
};
/** internal */
template < typename... TArgs >
void
@ -132,7 +143,7 @@ namespace llarp
#endif
std::string tag = fname;
ss << _glog.nodeName << " (" << thread_id_string() << ") "
<< llarp_time_now_ms() << " " << tag << ":" << lineno;
<< log_timestamp() << " " << tag << ":" << lineno;
ss << "\t";
LogAppend(ss, std::forward< TArgs >(args)...);
#ifndef ANDROID

@ -2,6 +2,7 @@
#include <llarp/router_contact.hpp>
#include <llarp/version.h>
#include <llarp/crypto.hpp>
#include <llarp/time.h>
#include "buffer.hpp"
#include "logger.hpp"
#include "mem.hpp"

@ -1,10 +1,8 @@
#include <llarp/time.h>
#include <chrono>
#include <llarp/time.hpp>
namespace llarp
{
typedef std::chrono::system_clock Clock_t;
template < typename Res >
static llarp_time_t
time_since_epoch()

Loading…
Cancel
Save