diff options
-rw-r--r-- | TODO | 5 | ||||
-rw-r--r-- | src/ConfigParser.cpp | 22 | ||||
-rw-r--r-- | src/FIRFilter.cpp | 19 | ||||
-rw-r--r-- | src/Flowgraph.cpp | 2 | ||||
-rw-r--r-- | src/Log.cpp | 5 | ||||
-rw-r--r-- | src/TimestampDecoder.h | 2 |
6 files changed, 26 insertions, 29 deletions
@@ -61,11 +61,6 @@ Smaller things Remove GuardIntervalInserter implementation for window==0, as it was shown both are equivalent. -Replace all prints to stderr ----------------------------- -We have a nice logging subsystem, use it to avoid that fprintf(stderr, ...) and -logging to stderr messages collide. - Finalise EDI input ------------------ The EDI input, based on work started in http://git.mpb.li/git/odr-edilib/ diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index 3c75026..62f1241 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -400,8 +400,7 @@ void parse_args(int argc, char **argv, mod_settings_t& mod_settings) case 'f': #if defined(HAVE_OUTPUT_UHD) if (mod_settings.useUHDOutput) { - fprintf(stderr, "Options -u and -f are mutually exclusive\n"); - throw std::invalid_argument("Invalid command line options"); + throw std::invalid_argument("Options -u and -f are mutually exclusive"); } #endif mod_settings.outputName = optarg; @@ -417,8 +416,7 @@ void parse_args(int argc, char **argv, mod_settings_t& mod_settings) } #endif else { - fprintf(stderr, "Cannot use -F before setting output!\n"); - throw std::invalid_argument("Invalid command line options"); + throw std::invalid_argument("Cannot use -F before setting output!"); } break; case 'g': @@ -450,8 +448,7 @@ void parse_args(int argc, char **argv, mod_settings_t& mod_settings) case 'u': #if defined(HAVE_OUTPUT_UHD) if (mod_settings.useFileOutput) { - fprintf(stderr, "Options -u and -f are mutually exclusive\n"); - throw std::invalid_argument("Invalid command line options"); + throw std::invalid_argument("Options -u and -f are mutually exclusive"); } mod_settings.sdr_device_config.device = optarg; mod_settings.sdr_device_config.refclk_src = "internal"; @@ -472,8 +469,10 @@ void parse_args(int argc, char **argv, mod_settings_t& mod_settings) throw std::invalid_argument(""); break; default: - fprintf(stderr, "Option '%c' not coded yet!\n", c); - throw std::invalid_argument("Invalid command line options"); + { + string optstr(1, c); + throw std::invalid_argument("Invalid command line option: -" + optstr); + } } } @@ -514,13 +513,12 @@ void parse_args(int argc, char **argv, mod_settings_t& mod_settings) // Checking unused arguments if (use_configuration_cmdline && optind != argc) { - fprintf(stderr, "Invalid arguments:"); + string invalid = "Invalid arguments:"; while (optind != argc) { - fprintf(stderr, " %s", argv[optind++]); + invalid += argv[optind++]; } - fprintf(stderr, "\n"); printUsage(argv[0]); - etiLog.level(error) << "Received invalid command line arguments"; + etiLog.level(error) << "Received invalid command line arguments: " + invalid; throw std::invalid_argument("Invalid command line options"); } diff --git a/src/FIRFilter.cpp b/src/FIRFilter.cpp index 96ad1b9..740d8ed 100644 --- a/src/FIRFilter.cpp +++ b/src/FIRFilter.cpp @@ -101,23 +101,21 @@ void FIRFilter::load_filter_taps(const std::string &tapsFile) } else { std::ifstream taps_fstream(tapsFile.c_str()); - if(!taps_fstream) { - fprintf(stderr, "FIRFilter: file %s could not be opened !\n", tapsFile.c_str()); - throw std::runtime_error("FIRFilter: Could not open file with taps! "); + if (!taps_fstream) { + throw std::runtime_error("FIRFilter: Could not open taps file " + tapsFile); } int n_taps; taps_fstream >> n_taps; if (n_taps <= 0) { - fprintf(stderr, "FIRFilter: warning: taps file has invalid format\n"); throw std::runtime_error("FIRFilter: taps file has invalid format."); } if (n_taps > 100) { - fprintf(stderr, "FIRFilter: warning: taps file has more than 100 taps\n"); + etiLog.level(warn) << "FIRFilter: warning: taps file has more than 100 taps"; } - fprintf(stderr, "FIRFilter: Reading %d taps...\n", n_taps); + etiLog.level(debug) << "FIRFilter: Reading " << n_taps << " taps..."; filter_taps.resize(n_taps); @@ -126,9 +124,11 @@ void FIRFilter::load_filter_taps(const std::string &tapsFile) taps_fstream >> filter_taps[n]; PDEBUG("FIRFilter: tap: %f\n", (double)filter_taps[n] ); if (taps_fstream.eof()) { - fprintf(stderr, "FIRFilter: file %s should contains %d taps, but EOF reached "\ - "after %d taps !\n", tapsFile.c_str(), n_taps, n); - throw std::runtime_error("FIRFilter: filtertaps file invalid ! "); + throw std::runtime_error( + "FIRFilter: file " + tapsFile + + " should contain " + to_string(n_taps) + + " taps, but EOF reached after " + to_string(n) + + " taps!"); } } } @@ -156,7 +156,6 @@ int FIRFilter::internal_process(Buffer* const dataIn, Buffer* dataOut) size_t sizeIn = dataIn->getLength() / sizeof(float); if ((uintptr_t)(&out[0]) % 16 != 0) { - fprintf(stderr, "FIRFilterWorker: out not aligned %p ", out); throw std::runtime_error("FIRFilterWorker: out not aligned"); } diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp index 506832c..c14280e 100644 --- a/src/Flowgraph.cpp +++ b/src/Flowgraph.cpp @@ -256,7 +256,7 @@ Flowgraph::~Flowgraph() myProcessTime); ss << node_time_sz; - fprintf(stderr, "%s", ss.str().c_str()); + etiLog.level(debug) << ss.str(); } } diff --git a/src/Log.cpp b/src/Log.cpp index f2219eb..ee16880 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -34,6 +34,11 @@ using namespace std; +/* This is called etiLog because it was copy-pasted from ODR-DabMux, even + * though it doesn't make any more sense there than here. + * + * It is a singleton used in all parts of ODR-DabMod to output log messages. + */ Logger etiLog; diff --git a/src/TimestampDecoder.h b/src/TimestampDecoder.h index 31c8bec..ed41dfb 100644 --- a/src/TimestampDecoder.h +++ b/src/TimestampDecoder.h @@ -88,7 +88,7 @@ struct frame_timestamp } void print(const char* t) const { - fprintf(stderr, + etiLog.log(debug, "%s <frame_timestamp(%s, %d, %.9f, %d)>\n", t, this->timestamp_valid ? "valid" : "invalid", this->timestamp_sec, pps_offset(), |