aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-01-12 22:23:37 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-01-12 22:23:37 +0100
commit27de21b5de1a9d0ac728a4b598ad2e5824fc500a (patch)
treef12f71ac4c709a42769196cb8222f906c72f4c20
parentf1874c259259a039227517a9cd58d7017a1bef34 (diff)
downloaddabmux-27de21b5de1a9d0ac728a4b598ad2e5824fc500a.tar.gz
dabmux-27de21b5de1a9d0ac728a4b598ad2e5824fc500a.tar.bz2
dabmux-27de21b5de1a9d0ac728a4b598ad2e5824fc500a.zip
improve debugging print, add print to stderr
-rw-r--r--src/Log.cpp2
-rw-r--r--src/Log.h4
-rw-r--r--src/utils.cpp78
3 files changed, 50 insertions, 34 deletions
diff --git a/src/Log.cpp b/src/Log.cpp
index 64e7ceb..7817243 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -66,6 +66,8 @@ void Logger::logstr(log_level_t level, const std::string message)
it++) {
(*it)->log(level, message);
}
+
+ std::cerr << levels_as_str[level] << " " << message;
}
diff --git a/src/Log.h b/src/Log.h
index d28f6c0..5c8c4b3 100644
--- a/src/Log.h
+++ b/src/Log.h
@@ -38,12 +38,16 @@
#include <list>
#include <stdexcept>
#include <string>
+#include <map>
#define SYSLOG_IDENT "CRC-DABMUX"
#define SYSLOG_FACILITY LOG_LOCAL0
enum log_level_t {debug = 0, info, warn, error, alert, emerg};
+const std::string levels_as_str[] =
+ { " ", " ", "WARN ", "ERROR", "ALERT", "EMERG"} ;
+
/** Abstract class all backends must inherit from */
class LogBackend {
public:
diff --git a/src/utils.cpp b/src/utils.cpp
index 09a3eb6..4213f28 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -54,68 +54,69 @@ void header_message()
"Her Majesty the Queen in Right of Canada,\n"
"(Communications Research Centre Canada) All rights reserved.\n\n"
"Copyright (C) 2013,2014\nMatthias P. Braendli, http://mpb.li\n\n");
- etiLog.log(info, "Input URLs supported:");
+
+ etiLog.level(info) << "Input URLs supported:" <<
#if defined(HAVE_INPUT_PRBS)
- etiLog.log(info, " prbs");
+ " prbs" <<
#endif
#if defined(HAVE_INPUT_TEST)
- etiLog.log(info, " test");
+ " test" <<
#endif
#if defined(HAVE_INPUT_SLIP)
- etiLog.log(info, " slip");
+ " slip" <<
#endif
#if defined(HAVE_INPUT_UDP)
- etiLog.log(info, " udp");
+ " udp" <<
#endif
#if defined(HAVE_INPUT_FIFO)
- etiLog.log(info, " fifo");
+ " fifo" <<
#endif
#if defined(HAVE_INPUT_FILE)
- etiLog.log(info, " file");
+ " file" <<
#endif
- etiLog.log(info, "\n");
+ "\n";
- etiLog.log(info, "Inputs format supported:");
+ etiLog.level(info) << "Inputs format supported:"
#if defined(HAVE_FORMAT_RAW)
- etiLog.log(info, " raw");
+ " raw" <<
#endif
#if defined(HAVE_FORMAT_BRIDGE)
- etiLog.log(info, " bridge");
+ " bridge" <<
#endif
#if defined(HAVE_FORMAT_MPEG)
- etiLog.log(info, " mpeg");
+ " mpeg" <<
#endif
#if defined(HAVE_FORMAT_PACKET)
- etiLog.log(info, " packet");
+ " packet" <<
#endif
#if defined(HAVE_FORMAT_DMB)
- etiLog.log(info, " dmb");
+ " dmb" <<
#endif
#if defined(HAVE_FORMAT_EPM)
- etiLog.log(info, " epm");
+ " epm" <<
#endif
- etiLog.log(info, "\n");
+ "\n";
- etiLog.log(info, "Output URLs supported:");
+ etiLog.level(info) << "Output URLs supported:"
#if defined(HAVE_OUTPUT_FILE)
- etiLog.log(info, " file");
+ " file" <<
#endif
#if defined(HAVE_OUTPUT_FIFO)
- etiLog.log(info, " fifo");
+ " fifo" <<
#endif
#if defined(HAVE_OUTPUT_UDP)
- etiLog.log(info, " udp");
+ " udp" <<
#endif
#if defined(HAVE_OUTPUT_TCP)
- etiLog.log(info, " tcp");
+ " tcp" <<
#endif
#if defined(HAVE_OUTPUT_RAW)
- etiLog.log(info, " raw");
+ " raw" <<
#endif
#if defined(HAVE_OUTPUT_SIMUL)
- etiLog.log(info, " simul");
+ " simul" <<
#endif
- etiLog.log(info, "\n\n");
+ "\n\n";
}
@@ -302,9 +303,12 @@ void printServices(vector<dabService*>& services)
etiLog.log(info, "Service %i\n", index);
etiLog.log(info, " label: %s\n", label);
etiLog.log(info, " short label: ");
- for (int i = 0; i < 32; ++i) {
- if ((*current)->label.flag & 0x8000 >> i) {
- etiLog.log(info, "%c", (*current)->label.text[i]);
+ {
+ LogLine line = etiLog.level(info);
+ for (int i = 0; i < 32; ++i) {
+ if ((*current)->label.flag & 0x8000 >> i) {
+ line << (*current)->label.text[i];
+ }
}
}
etiLog.log(info, " (0x%x)\n", (*current)->label.flag);
@@ -346,9 +350,12 @@ void printComponent(dabComponent* component)
etiLog.log(info, " label: %s\n",
label);
etiLog.log(info, " short label: ");
- for (int i = 0; i < 32; ++i) {
- if (component->label.flag & 0x8000 >> i) {
- etiLog.log(info, "%c", component->label.text[i]);
+ {
+ LogLine line = etiLog.level(info);
+ for (int i = 0; i < 32; ++i) {
+ if (component->label.flag & 0x8000 >> i) {
+ line << component->label.text[i];
+ }
}
}
etiLog.log(info, " (0x%x)\n", component->label.flag);
@@ -440,10 +447,13 @@ void printEnsemble(dabEnsemble* ensemble)
etiLog.log(info, " ecc: 0x%x (%u)\n",
ensemble->ecc, ensemble->ecc);
etiLog.log(info, " label: %s\n", label);
- etiLog.log(info, " short label: ");
- for (int i = 0; i < 32; ++i) {
- if (ensemble->label.flag & 0x8000 >> i) {
- etiLog.log(info, "%c", ensemble->label.text[i]);
+ {
+ LogLine line = etiLog.level(info);
+ line << " short label: ";
+ for (int i = 0; i < 32; ++i) {
+ if (ensemble->label.flag & 0x8000 >> i) {
+ line << ensemble->label.text[i];
+ }
}
}
etiLog.log(info, " (0x%x)\n", ensemble->label.flag);