mirror of https://github.com/oxen-io/lokinet
make format and readd win32 console color logging
This commit is contained in:
parent
fda7c4779e
commit
5399b93270
|
@ -28,7 +28,8 @@ namespace abyss
|
|||
if(ShouldProcessHeader(string_view(lowerHeader)))
|
||||
{
|
||||
val = val.substr(val.find_first_not_of(' '));
|
||||
Header.Headers.emplace(lowerHeader.c_str(), llarp::string_view_string(val));
|
||||
Header.Headers.emplace(lowerHeader.c_str(),
|
||||
llarp::string_view_string(val));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace llarp
|
|||
friend std::ostream &
|
||||
operator<<(std::ostream &out, const SecretKey &)
|
||||
{
|
||||
//return out << k.ToHex();
|
||||
// return out << k.ToHex();
|
||||
// make sure we never print out secret keys
|
||||
return out << "[secretkey]";
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ namespace llarp
|
|||
friend std::ostream &
|
||||
operator<<(std::ostream &out, const IdentitySecret &)
|
||||
{
|
||||
//return out << k.ToHex();
|
||||
// return out << k.ToHex();
|
||||
// make sure we never print out secret keys
|
||||
return out << "[secretkey]";
|
||||
}
|
||||
|
|
|
@ -232,12 +232,14 @@ namespace llarp
|
|||
ListNeighboors() const
|
||||
{
|
||||
Response resp = Response::array();
|
||||
router->ForEachPeer([&](const ILinkSession* session, bool outbound) {
|
||||
resp.emplace_back(
|
||||
Response{{"ident", RouterID(session->GetPubKey()).ToString()},
|
||||
{"addr", session->GetRemoteEndpoint().ToString()},
|
||||
{"outbound", outbound}});
|
||||
}, false);
|
||||
router->ForEachPeer(
|
||||
[&](const ILinkSession* session, bool outbound) {
|
||||
resp.emplace_back(
|
||||
Response{{"ident", RouterID(session->GetPubKey()).ToString()},
|
||||
{"addr", session->GetRemoteEndpoint().ToString()},
|
||||
{"outbound", outbound}});
|
||||
},
|
||||
false);
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@ namespace llarp
|
|||
llarp::service::Config::section_t values;
|
||||
values.first.assign(name.begin(), name.end());
|
||||
for(const auto& item : section)
|
||||
values.second.emplace_back(string_view_string(item.first), string_view_string(item.second));
|
||||
values.second.emplace_back(string_view_string(item.first),
|
||||
string_view_string(item.second));
|
||||
services.emplace_back(values);
|
||||
});
|
||||
return services.size() > 0;
|
||||
|
|
|
@ -16,8 +16,8 @@ struct llarp_threadpool
|
|||
std::queue< std::function< void(void) > > jobs GUARDED_BY(m_access);
|
||||
|
||||
llarp_threadpool(int workers, const char *name)
|
||||
: impl(
|
||||
std::make_unique< llarp::thread::ThreadPool >(workers, workers * 128))
|
||||
: impl(std::make_unique< llarp::thread::ThreadPool >(workers,
|
||||
workers * 128))
|
||||
{
|
||||
(void)name;
|
||||
}
|
||||
|
|
|
@ -26,20 +26,34 @@ namespace llarp
|
|||
{
|
||||
if(!isConsoleModern)
|
||||
{
|
||||
GetConsoleScreenBufferInfo(fd1, &consoleInfo);
|
||||
old_attrs = consoleInfo.wAttributes;
|
||||
switch(lvl)
|
||||
{
|
||||
case eLogNone:
|
||||
break;
|
||||
case eLogDebug:
|
||||
SetConsoleTextAttribute(fd1,
|
||||
FOREGROUND_RED | FOREGROUND_GREEN
|
||||
| FOREGROUND_BLUE); // low white on black
|
||||
ss << "[DBG] ";
|
||||
break;
|
||||
case eLogInfo:
|
||||
SetConsoleTextAttribute(
|
||||
fd1,
|
||||
FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN
|
||||
| FOREGROUND_BLUE); // high white on black
|
||||
ss << "[NFO] ";
|
||||
break;
|
||||
case eLogWarn:
|
||||
SetConsoleTextAttribute(fd1,
|
||||
FOREGROUND_RED | FOREGROUND_GREEN
|
||||
| FOREGROUND_INTENSITY); // bright yellow
|
||||
ss << "[WRN] ";
|
||||
break;
|
||||
case eLogError:
|
||||
SetConsoleTextAttribute(
|
||||
fd1, FOREGROUND_RED | FOREGROUND_INTENSITY); // bright red
|
||||
ss << "[ERR] ";
|
||||
break;
|
||||
}
|
||||
|
@ -53,10 +67,14 @@ namespace llarp
|
|||
void
|
||||
Win32LogStream::PostLog(std::stringstream& ss) const
|
||||
{
|
||||
if(isConsoleModern)
|
||||
OStreamLogStream::PostLog(ss);
|
||||
else
|
||||
if(!isConsoleModern)
|
||||
{
|
||||
SetConsoleTextAttribute(
|
||||
fd1, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
ss << std::endl;
|
||||
}
|
||||
else
|
||||
OStreamLogStream::PostLog(ss);
|
||||
}
|
||||
} // namespace llarp
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue