aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/salticidae/network.h15
-rw-r--r--include/salticidae/util.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/include/salticidae/network.h b/include/salticidae/network.h
index a71c5dd..1e63efa 100644
--- a/include/salticidae/network.h
+++ b/include/salticidae/network.h
@@ -601,8 +601,19 @@ bool PeerNetwork<O, _, __>::check_new_conn(const conn_t &conn, uint16_t port) {
p->reset_ping_timer();
p->send_ping();
if (p->connected)
- SALTICIDAE_LOG_INFO("PeerNetwork: established connection with %s via %s",
- std::string(conn->peer_id).c_str(), std::string(*conn).c_str());
+ {
+ auto color_begin = "";
+ auto color_end = "";
+ if (logger.is_tty())
+ {
+ color_begin = TTY_COLOR_BLUE;
+ color_end = TTY_COLOR_RESET;
+ }
+ SALTICIDAE_LOG_INFO("%sPeerNetwork: established connection with %s via %s%s",
+ color_begin,
+ std::string(conn->peer_id).c_str(), std::string(*conn).c_str(),
+ color_end);
+ }
return false;
}
diff --git a/include/salticidae/util.h b/include/salticidae/util.h
index ed7d980..c640de7 100644
--- a/include/salticidae/util.h
+++ b/include/salticidae/util.h
@@ -101,6 +101,7 @@ class Logger {
void debug(const char *fmt, ...);
void warning(const char *fmt, ...);
void error(const char *fmt, ...);
+ bool is_tty() { return isatty(output); }
};
extern Logger logger;