update logging to use human readable time

This commit is contained in:
Jeff 2018-10-08 07:56:17 -04:00
parent 291cc57395
commit a1d1518bc0
6 changed files with 19 additions and 7 deletions

View File

@ -29,7 +29,7 @@ namespace llarp
bool bool
operator<(const RCNode& other) const 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 bool
operator<(const ISNode& other) const operator<(const ISNode& other) const
{ {
return introset.OtherIsNewer(other.introset); return introset.T < other.introset.T;
} }
}; };
} // namespace dht } // namespace dht

View File

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

View File

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

View File

@ -1,6 +1,6 @@
#ifndef LLARP_LOGGER_HPP #ifndef LLARP_LOGGER_HPP
#define LLARP_LOGGER_HPP #define LLARP_LOGGER_HPP
#include <llarp/time.h> #include <llarp/time.hpp>
#include <ctime> #include <ctime>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
@ -79,6 +79,17 @@ namespace llarp
return std::to_string(id); 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 */ /** internal */
template < typename... TArgs > template < typename... TArgs >
void void
@ -132,7 +143,7 @@ namespace llarp
#endif #endif
std::string tag = fname; std::string tag = fname;
ss << _glog.nodeName << " (" << thread_id_string() << ") " ss << _glog.nodeName << " (" << thread_id_string() << ") "
<< llarp_time_now_ms() << " " << tag << ":" << lineno; << log_timestamp() << " " << tag << ":" << lineno;
ss << "\t"; ss << "\t";
LogAppend(ss, std::forward< TArgs >(args)...); LogAppend(ss, std::forward< TArgs >(args)...);
#ifndef ANDROID #ifndef ANDROID

View File

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

View File

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