diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-10-09 13:44:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-10-09 13:45:12 +0100 |
| commit | aeb835a18c8df347e0ed68fb24631b320abeb611 (patch) | |
| tree | 01746a2d872aad8127a1442326ac720756172a17 /src/lib/server.cc | |
| parent | 4d9f56686380aed5eb3e17ab9e720df57a17f079 (diff) | |
Logging improvements to allow prettier displays in the server GUI.
Diffstat (limited to 'src/lib/server.cc')
| -rw-r--r-- | src/lib/server.cc | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/lib/server.cc b/src/lib/server.cc index f0b2d9816..5d85d8800 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -35,6 +35,7 @@ #include "raw_convert.h" #include "compose.hpp" #include "log.h" +#include "encoded_log_entry.h" #include <libcxml/cxml.h> #include <libxml++/libxml++.h> #include <boost/algorithm/string.hpp> @@ -46,10 +47,10 @@ #include "i18n.h" -#define LOG_GENERAL(...) _log->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL); -#define LOG_GENERAL_NC(...) _log->log (__VA_ARGS__, Log::TYPE_GENERAL); -#define LOG_ERROR(...) _log->log (String::compose (__VA_ARGS__), Log::TYPE_ERROR); -#define LOG_ERROR_NC(...) _log->log (__VA_ARGS__, Log::TYPE_ERROR); +#define LOG_GENERAL(...) _log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL_NC(...) _log->log (__VA_ARGS__, LogEntry::TYPE_GENERAL); +#define LOG_ERROR(...) _log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_ERROR); +#define LOG_ERROR_NC(...) _log->log (__VA_ARGS__, LogEntry::TYPE_ERROR); using std::string; using std::vector; @@ -187,19 +188,20 @@ Server::worker_thread () struct timeval end; gettimeofday (&end, 0); - SafeStringStream message; - message.precision (2); - message << fixed - << "Encoded frame " << frame << " from " << ip << ": " - << "receive " << (seconds(after_read) - seconds(start)) << "s " - << "encode " << (seconds(after_encode) - seconds(after_read)) << "s " - << "send " << (seconds(end) - seconds(after_encode)) << "s."; + shared_ptr<EncodedLogEntry> e ( + new EncodedLogEntry ( + frame, ip, + seconds(after_read) - seconds(start), + seconds(after_encode) - seconds(after_read), + seconds(end) - seconds(after_encode) + ) + ); if (_verbose) { - cout << message.str() << "\n"; + cout << e->get() << "\n"; } - LOG_GENERAL_NC (message.str ()); + _log->log (e); } _full_condition.notify_all (); |
