make format and readd win32 console color logging

pull/506/head
Jeff Becker 5 years ago
parent fda7c4779e
commit 5399b93270
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -28,7 +28,8 @@ namespace abyss
if(ShouldProcessHeader(string_view(lowerHeader))) if(ShouldProcessHeader(string_view(lowerHeader)))
{ {
val = val.substr(val.find_first_not_of(' ')); 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; return true;
} }

@ -91,7 +91,7 @@ namespace llarp
friend std::ostream & friend std::ostream &
operator<<(std::ostream &out, const SecretKey &) operator<<(std::ostream &out, const SecretKey &)
{ {
//return out << k.ToHex(); // return out << k.ToHex();
// make sure we never print out secret keys // make sure we never print out secret keys
return out << "[secretkey]"; return out << "[secretkey]";
} }
@ -132,7 +132,7 @@ namespace llarp
friend std::ostream & friend std::ostream &
operator<<(std::ostream &out, const IdentitySecret &) operator<<(std::ostream &out, const IdentitySecret &)
{ {
//return out << k.ToHex(); // return out << k.ToHex();
// make sure we never print out secret keys // make sure we never print out secret keys
return out << "[secretkey]"; return out << "[secretkey]";
} }

@ -232,12 +232,14 @@ namespace llarp
ListNeighboors() const ListNeighboors() const
{ {
Response resp = Response::array(); Response resp = Response::array();
router->ForEachPeer([&](const ILinkSession* session, bool outbound) { router->ForEachPeer(
resp.emplace_back( [&](const ILinkSession* session, bool outbound) {
Response{{"ident", RouterID(session->GetPubKey()).ToString()}, resp.emplace_back(
{"addr", session->GetRemoteEndpoint().ToString()}, Response{{"ident", RouterID(session->GetPubKey()).ToString()},
{"outbound", outbound}}); {"addr", session->GetRemoteEndpoint().ToString()},
}, false); {"outbound", outbound}});
},
false);
return resp; return resp;
} }

@ -17,7 +17,8 @@ namespace llarp
llarp::service::Config::section_t values; llarp::service::Config::section_t values;
values.first.assign(name.begin(), name.end()); values.first.assign(name.begin(), name.end());
for(const auto& item : section) 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); services.emplace_back(values);
}); });
return services.size() > 0; return services.size() > 0;

@ -16,8 +16,8 @@ struct llarp_threadpool
std::queue< std::function< void(void) > > jobs GUARDED_BY(m_access); std::queue< std::function< void(void) > > jobs GUARDED_BY(m_access);
llarp_threadpool(int workers, const char *name) llarp_threadpool(int workers, const char *name)
: impl( : impl(std::make_unique< llarp::thread::ThreadPool >(workers,
std::make_unique< llarp::thread::ThreadPool >(workers, workers * 128)) workers * 128))
{ {
(void)name; (void)name;
} }

@ -26,20 +26,34 @@ namespace llarp
{ {
if(!isConsoleModern) if(!isConsoleModern)
{ {
GetConsoleScreenBufferInfo(fd1, &consoleInfo);
old_attrs = consoleInfo.wAttributes;
switch(lvl) switch(lvl)
{ {
case eLogNone: case eLogNone:
break; break;
case eLogDebug: case eLogDebug:
SetConsoleTextAttribute(fd1,
FOREGROUND_RED | FOREGROUND_GREEN
| FOREGROUND_BLUE); // low white on black
ss << "[DBG] "; ss << "[DBG] ";
break; break;
case eLogInfo: case eLogInfo:
SetConsoleTextAttribute(
fd1,
FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN
| FOREGROUND_BLUE); // high white on black
ss << "[NFO] "; ss << "[NFO] ";
break; break;
case eLogWarn: case eLogWarn:
SetConsoleTextAttribute(fd1,
FOREGROUND_RED | FOREGROUND_GREEN
| FOREGROUND_INTENSITY); // bright yellow
ss << "[WRN] "; ss << "[WRN] ";
break; break;
case eLogError: case eLogError:
SetConsoleTextAttribute(
fd1, FOREGROUND_RED | FOREGROUND_INTENSITY); // bright red
ss << "[ERR] "; ss << "[ERR] ";
break; break;
} }
@ -53,10 +67,14 @@ namespace llarp
void void
Win32LogStream::PostLog(std::stringstream& ss) const Win32LogStream::PostLog(std::stringstream& ss) const
{ {
if(isConsoleModern) if(!isConsoleModern)
OStreamLogStream::PostLog(ss); {
else SetConsoleTextAttribute(
fd1, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
ss << std::endl; ss << std::endl;
}
else
OStreamLogStream::PostLog(ss);
} }
} // namespace llarp } // namespace llarp
#endif #endif

Loading…
Cancel
Save