aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Braendli <matthias.braendli@u-blox.com>2015-06-02 12:25:40 +0200
committerMatthias Braendli <matthias.braendli@u-blox.com>2015-06-02 12:27:42 +0200
commite3cc55d32281be5dd7b7017d6dfed42be24d3cda (patch)
treec589cedc7bd1cabfdf1aee9a65f00037006e7c22
parent7eaba8024b95bb346247c828748d2292c226d19f (diff)
downloaddabmod-e3cc55d32281be5dd7b7017d6dfed42be24d3cda.tar.gz
dabmod-e3cc55d32281be5dd7b7017d6dfed42be24d3cda.tar.bz2
dabmod-e3cc55d32281be5dd7b7017d6dfed42be24d3cda.zip
Logging: use etiLog instead of stderr
-rw-r--r--src/DabMod.cpp57
-rw-r--r--src/DabModulator.cpp4
-rw-r--r--src/DabModulator.h3
-rw-r--r--src/EtiReader.cpp6
-rw-r--r--src/EtiReader.h5
-rw-r--r--src/InputFileReader.cpp49
-rw-r--r--src/InputReader.h10
-rw-r--r--src/InputZeroMQReader.cpp19
-rw-r--r--src/Log.cpp2
-rw-r--r--src/OutputUHD.cpp74
-rw-r--r--src/OutputUHD.h11
-rw-r--r--src/RemoteControl.h5
-rw-r--r--src/TimestampDecoder.cpp10
-rw-r--r--src/TimestampDecoder.h12
14 files changed, 112 insertions, 155 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index dacc84e..2fe8d53 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -108,7 +108,7 @@ enum run_modulator_state {
MOD_AGAIN
};
-run_modulator_state run_modulator(Logger& logger, modulator_data& m);
+run_modulator_state run_modulator(modulator_data& m);
int launch_modulator(int argc, char* argv[])
{
@@ -171,10 +171,9 @@ int launch_modulator(int argc, char* argv[])
bool run_again = true;
- Logger logger;
- InputFileReader inputFileReader(logger);
+ InputFileReader inputFileReader;
#if defined(HAVE_ZEROMQ)
- shared_ptr<InputZeroMQReader> inputZeroMQReader(new InputZeroMQReader(logger));
+ shared_ptr<InputZeroMQReader> inputZeroMQReader(new InputZeroMQReader());
#endif
struct sigaction sa;
@@ -402,7 +401,7 @@ int launch_modulator(int argc, char* argv[])
// log parameters:
if (pt.get("log.syslog", 0) == 1) {
LogToSyslog* log_syslog = new LogToSyslog();
- logger.register_backend(log_syslog);
+ etiLog.register_backend(log_syslog);
}
if (pt.get("log.filelog", 0) == 1) {
@@ -417,7 +416,7 @@ int launch_modulator(int argc, char* argv[])
}
LogToFile* log_file = new LogToFile(logfilename);
- logger.register_backend(log_file);
+ etiLog.register_backend(log_file);
}
@@ -605,15 +604,15 @@ int launch_modulator(int argc, char* argv[])
}
if (rcs.get_no_controllers() == 0) {
- logger.level(warn) << "No Remote-Control started";
+ etiLog.level(warn) << "No Remote-Control started";
rcs.add_controller(new RemoteControllerDummy());
}
- logger.level(info) << "Starting up";
+ etiLog.level(info) << "Starting up";
if (!(modconf.use_offset_file || modconf.use_offset_fixed)) {
- logger.level(debug) << "No Modulator offset defined, setting to 0";
+ etiLog.level(debug) << "No Modulator offset defined, setting to 0";
modconf.use_offset_fixed = true;
modconf.offset_fixed = 0;
}
@@ -649,12 +648,12 @@ int launch_modulator(int argc, char* argv[])
fprintf(stderr, "\n");
printUsage(argv[0]);
ret = -1;
- logger.level(error) << "Received invalid command line arguments";
+ etiLog.level(error) << "Received invalid command line arguments";
throw std::invalid_argument("Invalid command line options");
}
if (!useFileOutput && !useUHDOutput && !useZeroMQOutput) {
- logger.level(error) << "Output not specified";
+ etiLog.level(error) << "Output not specified";
fprintf(stderr, "Must specify output !");
throw std::runtime_error("Configuration error");
}
@@ -706,7 +705,7 @@ int launch_modulator(int argc, char* argv[])
// Opening ETI input file
if (inputFileReader.Open(inputName, loop) == -1) {
fprintf(stderr, "Unable to open input file!\n");
- logger.level(error) << "Unable to open input file!";
+ etiLog.level(error) << "Unable to open input file!";
ret = -1;
throw std::runtime_error("Unable to open input");
}
@@ -747,7 +746,7 @@ int launch_modulator(int argc, char* argv[])
else if (useUHDOutput) {
normalise = 1.0f / normalise_factor;
outputuhd_conf.sampleRate = outputRate;
- output = make_shared<OutputUHD>(outputuhd_conf, &logger);
+ output = make_shared<OutputUHD>(outputuhd_conf);
((OutputUHD*)output.get())->enrol_at(rcs);
}
#endif
@@ -778,7 +777,7 @@ int launch_modulator(int argc, char* argv[])
shared_ptr<InputMemory> input(new InputMemory(&m.data));
shared_ptr<DabModulator> modulator(
- new DabModulator(modconf, &rcs, logger, outputRate, clockRate,
+ new DabModulator(modconf, &rcs, outputRate, clockRate,
dabMode, gainMode, digitalgain, normalise, filterTapsFilename));
flowgraph.connect(input, modulator);
@@ -798,23 +797,23 @@ int launch_modulator(int argc, char* argv[])
m.inputReader->PrintInfo();
- run_modulator_state st = run_modulator(logger, m);
+ run_modulator_state st = run_modulator(m);
switch (st) {
case MOD_FAILURE:
- fprintf(stderr, "\nModulator failure.\n");
+ etiLog.level(error) << "Modulator failure.";
run_again = false;
ret = 1;
break;
#if defined(HAVE_ZEROMQ)
case MOD_AGAIN:
- fprintf(stderr, "\nRestart modulator\n");
+ etiLog.level(warn) << "Restart modulator.";
running = true;
if (inputTransport == "zeromq") {
run_again = true;
// Create a new input reader
- inputZeroMQReader = make_shared<InputZeroMQReader>(logger);
+ inputZeroMQReader = make_shared<InputZeroMQReader>();
inputZeroMQReader->Open(inputName, inputMaxFramesQueued);
m.inputReader = inputZeroMQReader.get();
}
@@ -822,17 +821,15 @@ int launch_modulator(int argc, char* argv[])
#endif
case MOD_NORMAL_END:
default:
- fprintf(stderr, "\nModulator stopped.\n");
+ etiLog.level(info) << "modulator stopped.";
ret = 0;
run_again = false;
break;
}
fprintf(stderr, "\n\n");
- fprintf(stderr, "%lu DAB frames encoded\n", m.framecount);
- fprintf(stderr, "%f seconds encoded\n", (float)m.framecount * 0.024f);
-
- fprintf(stderr, "\nCleaning flowgraph...\n");
+ etiLog.level(info) << m.framecount << " DAB frames encoded";
+ etiLog.level(info) << ((float)m.framecount * 0.024f) << " seconds encoded";
m.data.setLength(0);
}
@@ -841,11 +838,11 @@ int launch_modulator(int argc, char* argv[])
// Cleaning things
////////////////////////////////////////////////////////////////////////
- logger.level(info) << "Terminating";
+ etiLog.level(info) << "Terminating";
return ret;
}
-run_modulator_state run_modulator(Logger& logger, modulator_data& m)
+run_modulator_state run_modulator(modulator_data& m)
{
run_modulator_state ret = MOD_FAILURE;
try {
@@ -879,10 +876,10 @@ run_modulator_state run_modulator(Logger& logger, modulator_data& m)
}
}
if (framesize == 0) {
- logger.level(info) << "End of file reached.";
+ etiLog.level(info) << "End of file reached.";
}
else {
- logger.level(error) << "Input read error.";
+ etiLog.level(error) << "Input read error.";
}
running = 0;
ret = MOD_NORMAL_END;
@@ -890,15 +887,15 @@ run_modulator_state run_modulator(Logger& logger, modulator_data& m)
#if defined(HAVE_OUTPUT_UHD)
} catch (fct_discontinuity_error& e) {
// The OutputUHD saw a FCT discontinuity
- logger.level(warn) << e.what();
+ etiLog.level(warn) << e.what();
ret = MOD_AGAIN;
#endif
} catch (zmq_input_overflow& e) {
// The ZeroMQ input has overflowed its buffer
- logger.level(warn) << e.what();
+ etiLog.level(warn) << e.what();
ret = MOD_AGAIN;
} catch (std::exception& e) {
- logger.level(error) << "Exception caught: " << e.what();
+ etiLog.level(error) << "Exception caught: " << e.what();
ret = MOD_FAILURE;
}
diff --git a/src/DabModulator.cpp b/src/DabModulator.cpp
index 667d885..4769502 100644
--- a/src/DabModulator.cpp
+++ b/src/DabModulator.cpp
@@ -57,21 +57,19 @@ using namespace boost;
DabModulator::DabModulator(
struct modulator_offset_config& modconf,
RemoteControllers* rcs,
- Logger& logger,
unsigned outputRate, unsigned clockRate,
unsigned dabMode, GainMode gainMode,
float digGain, float normalise,
std::string filterTapsFilename
) :
ModCodec(ModFormat(1), ModFormat(0)),
- myLogger(logger),
myOutputRate(outputRate),
myClockRate(clockRate),
myDabMode(dabMode),
myGainMode(gainMode),
myDigGain(digGain),
myNormalise(normalise),
- myEtiReader(EtiReader(modconf, myLogger)),
+ myEtiReader(EtiReader(modconf)),
myFlowgraph(NULL),
myFilterTapsFilename(filterTapsFilename),
myRCs(rcs)
diff --git a/src/DabModulator.h b/src/DabModulator.h
index 89ddd7c..5337f8c 100644
--- a/src/DabModulator.h
+++ b/src/DabModulator.h
@@ -51,7 +51,6 @@ public:
DabModulator(
struct modulator_offset_config& modconf,
RemoteControllers* rcs,
- Logger& logger,
unsigned outputRate = 2048000, unsigned clockRate = 0,
unsigned dabMode = 0, GainMode gainMode = GAIN_VAR,
float digGain = 1.0, float normalise = 1.0,
@@ -66,8 +65,6 @@ public:
EtiReader* getEtiReader() { return &myEtiReader; }
protected:
- Logger& myLogger;
-
void setMode(unsigned mode);
unsigned myOutputRate;
diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp
index 0e4182d..100fbdb 100644
--- a/src/EtiReader.cpp
+++ b/src/EtiReader.cpp
@@ -51,12 +51,10 @@ enum ETI_READER_STATE {
};
-EtiReader::EtiReader(struct modulator_offset_config& modconf,
- Logger& logger) :
- myLogger(logger),
+EtiReader::EtiReader(struct modulator_offset_config& modconf) :
state(EtiReaderStateSync),
myFicSource(NULL),
- myTimestampDecoder(modconf, myLogger)
+ myTimestampDecoder(modconf)
{
PDEBUG("EtiReader::EtiReader()\n");
diff --git a/src/EtiReader.h b/src/EtiReader.h
index b893f01..58a1976 100644
--- a/src/EtiReader.h
+++ b/src/EtiReader.h
@@ -47,7 +47,7 @@
class EtiReader
{
public:
- EtiReader(struct modulator_offset_config& modconf, Logger& logger);
+ EtiReader(struct modulator_offset_config& modconf);
virtual ~EtiReader();
EtiReader(const EtiReader&);
EtiReader& operator=(const EtiReader&);
@@ -67,9 +67,6 @@ public:
bool sourceContainsTimestamp();
protected:
- /* Main program logger */
- Logger& myLogger;
-
/* Transform the ETI TIST to a PPS offset in ms */
double getPPSOffset();
diff --git a/src/InputFileReader.cpp b/src/InputFileReader.cpp
index 205fbfa..84f0be4 100644
--- a/src/InputFileReader.cpp
+++ b/src/InputFileReader.cpp
@@ -49,8 +49,7 @@ int InputFileReader::Open(std::string filename, bool loop)
loop_ = loop;
inputfile_ = fopen(filename_.c_str(), "r");
if (inputfile_ == NULL) {
- fprintf(stderr, "Unable to open input file!\n");
- logger_.level(error) << "Unable to open input file!";
+ etiLog.level(error) << "Unable to open input file!";
perror(filename_.c_str());
return -1;
}
@@ -79,8 +78,7 @@ int InputFileReader::IdentifyType()
char discard_buffer[6144];
if (fread(&sync, sizeof(sync), 1, inputfile_) != 1) {
- fprintf(stderr, "Unable to read sync in input file!\n");
- logger_.level(error) << "Unable to read sync in input file!";
+ etiLog.level(error) << "Unable to read sync in input file!";
perror(filename_.c_str());
return -1;
}
@@ -96,8 +94,7 @@ int InputFileReader::IdentifyType()
// if the seek fails, consume the rest of the frame
if (fread(discard_buffer, 6144 - sizeof(sync), 1, inputfile_)
!= 1) {
- fprintf(stderr, "Unable to read from input file!\n");
- logger_.level(error) << "Unable to read from input file!";
+ etiLog.level(error) << "Unable to read from input file!";
perror(filename_.c_str());
return -1;
}
@@ -108,8 +105,7 @@ int InputFileReader::IdentifyType()
nbFrames = sync;
if (fread(&frameSize, sizeof(frameSize), 1, inputfile_) != 1) {
- fprintf(stderr, "Unable to read frame size in input file!\n");
- logger_.level(error) << "Unable to read frame size in input file!";
+ etiLog.level(error) << "Unable to read frame size in input file!";
perror(filename_.c_str());
return -1;
}
@@ -130,8 +126,7 @@ int InputFileReader::IdentifyType()
// if the seek fails, consume the rest of the frame
if (fread(discard_buffer, frameSize - 4, 1, inputfile_)
!= 1) {
- fprintf(stderr, "Unable to read from input file!\n");
- logger_.level(error) << "Unable to read from input file!";
+ etiLog.level(error) << "Unable to read from input file!";
perror(filename_.c_str());
return -1;
}
@@ -141,8 +136,7 @@ int InputFileReader::IdentifyType()
}
if (fread(&sync, sizeof(sync), 1, inputfile_) != 1) {
- fprintf(stderr, "Unable to read nb frame in input file!\n");
- logger_.level(error) << "Unable to read nb frame in input file!";
+ etiLog.level(error) << "Unable to read nb frame in input file!";
perror(filename_.c_str());
return -1;
}
@@ -152,8 +146,7 @@ int InputFileReader::IdentifyType()
// if the seek fails, consume the rest of the frame
if (fread(discard_buffer, frameSize - 4, 1, inputfile_)
!= 1) {
- fprintf(stderr, "Unable to read from input file!\n");
- logger_.level(error) << "Unable to read from input file!";
+ etiLog.level(error) << "Unable to read from input file!";
perror(filename_.c_str());
return -1;
}
@@ -168,8 +161,7 @@ int InputFileReader::IdentifyType()
sync >>= 8;
sync &= 0xffffff;
if (fread((uint8_t*)&sync + 3, 1, 1, inputfile_) != 1) {
- fprintf(stderr, "Unable to read from input file!\n");
- logger_.level(error) << "Unable to read from input file!";
+ etiLog.level(error) << "Unable to read from input file!";
perror(filename_.c_str());
return -1;
}
@@ -184,8 +176,7 @@ int InputFileReader::IdentifyType()
if (fseek(inputfile_, -sizeof(sync), SEEK_CUR) != 0) {
if (fread(discard_buffer, 6144 - sizeof(sync), 1, inputfile_)
!= 1) {
- fprintf(stderr, "Unable to read from input file!\n");
- logger_.level(error) << "Unable to read from input file!";
+ etiLog.level(error) << "Unable to read from input file!";
perror(filename_.c_str());
return -1;
}
@@ -195,8 +186,7 @@ int InputFileReader::IdentifyType()
}
}
- fprintf(stderr, "Bad input file format!\n");
- logger_.level(error) << "Bad input file format!";
+ etiLog.level(error) << "Bad input file format!";
return -1;
}
@@ -236,18 +226,18 @@ int InputFileReader::GetNextFrame(void* buffer)
}
else {
if (fread(&frameSize, sizeof(frameSize), 1, inputfile_) != 1) {
- logger_.level(error) << "Reached end of file.";
+ etiLog.level(error) << "Reached end of file.";
if (loop_) {
if (Rewind() == 0) {
if (fread(&frameSize, sizeof(frameSize), 1, inputfile_) != 1) {
PDEBUG("Error after rewinding file!\n");
- logger_.level(error) << "Error after rewinding file!";
+ etiLog.level(error) << "Error after rewinding file!";
return -1;
}
}
else {
PDEBUG("Impossible to rewind file!\n");
- logger_.level(error) << "Impossible to rewind file!";
+ etiLog.level(error) << "Impossible to rewind file!";
return -1;
}
}
@@ -257,8 +247,7 @@ int InputFileReader::GetNextFrame(void* buffer)
}
}
if (frameSize > 6144) { // there might be a better limit
- logger_.level(error) << "Wrong frame size " << frameSize << " in ETI file!";
- fprintf(stderr, "Wrong frame size %u in ETI file!\n", frameSize);
+ etiLog.level(error) << "Wrong frame size " << frameSize << " in ETI file!";
return -1;
}
@@ -275,7 +264,7 @@ int InputFileReader::GetNextFrame(void* buffer)
}
else {
PDEBUG("Impossible to rewind file!\n");
- logger_.level(error) << "Impossible to rewind file!";
+ etiLog.level(error) << "Impossible to rewind file!";
return -1;
}
}
@@ -285,12 +274,8 @@ int InputFileReader::GetNextFrame(void* buffer)
// A short read of a frame (i.e. reading an incomplete frame)
// is not tolerated. Input files must not contain incomplete frames
if (read_bytes != 0) {
- fprintf(stderr,
- "Unable to read a complete frame of %u data bytes from input file!\n",
- frameSize);
-
- perror(filename_.c_str());
- logger_.level(error) << "Unable to read from input file!";
+ etiLog.level(error) <<
+ "Unable to read a complete frame of " << frameSize << " data bytes from input file!";
return -1;
}
else {
diff --git a/src/InputReader.h b/src/InputReader.h
index c4e778b..37aa523 100644
--- a/src/InputReader.h
+++ b/src/InputReader.h
@@ -87,9 +87,9 @@ class InputReader
class InputFileReader : public InputReader
{
public:
- InputFileReader(Logger logger) :
+ InputFileReader() :
streamtype_(ETI_STREAM_TYPE_NONE),
- inputfile_(NULL), logger_(logger) {};
+ inputfile_(NULL) { }
~InputFileReader()
{
@@ -128,7 +128,6 @@ class InputFileReader : public InputReader
std::string filename_;
EtiStreamType streamtype_;
FILE* inputfile_;
- Logger logger_;
size_t inputfilelength_;
uint64_t nbframes_; // 64-bit because 32-bit overflow is
@@ -184,8 +183,8 @@ class InputZeroMQWorker
class InputZeroMQReader : public InputReader
{
public:
- InputZeroMQReader(Logger logger) :
- logger_(logger), in_messages_(10)
+ InputZeroMQReader() :
+ in_messages_(10)
{
workerdata_.in_messages = &in_messages_;
workerdata_.running = false;
@@ -203,7 +202,6 @@ class InputZeroMQReader : public InputReader
void PrintInfo();
private:
- Logger logger_;
InputZeroMQReader(const InputZeroMQReader& other);
InputZeroMQReader& operator=(const InputZeroMQReader& other);
std::string uri_;
diff --git a/src/InputZeroMQReader.cpp b/src/InputZeroMQReader.cpp
index eb50669..8706e1e 100644
--- a/src/InputZeroMQReader.cpp
+++ b/src/InputZeroMQReader.cpp
@@ -134,16 +134,14 @@ void InputZeroMQWorker::RecvProcess(struct InputZeroMQThreadData* workerdata)
}
else if (queue_size < workerdata->max_queued_frames) {
if (buffer_full) {
- fprintf(stderr, "ZeroMQ buffer recovered: %zu elements\n",
- queue_size);
+ etiLog.level(info) << "ZeroMQ buffer recovered: " << queue_size << " elements";
buffer_full = false;
}
zmq_dab_message_t* dab_msg = (zmq_dab_message_t*)incoming.data();
if (dab_msg->version != 1) {
- fprintf(stderr, "ZeroMQ input: wrong packet version %d\n",
- dab_msg->version);
+ etiLog.level(error) << "ZeroMQ wrong packet version " << dab_msg->version;
}
int offset = sizeof(dab_msg->version) +
@@ -154,8 +152,8 @@ void InputZeroMQWorker::RecvProcess(struct InputZeroMQThreadData* workerdata)
if (dab_msg->buflen[i] <= 0 ||
dab_msg->buflen[i] > 6144)
{
- fprintf(stderr, "ZeroMQ buffer %d: invalid length %d\n",
- i, dab_msg->buflen[i]);
+ etiLog.level(error) << "ZeroMQ buffer " << i << " has invalid length " <<
+ dab_msg->buflen[i];
// TODO error handling
}
else {
@@ -178,7 +176,7 @@ void InputZeroMQWorker::RecvProcess(struct InputZeroMQThreadData* workerdata)
workerdata->in_messages->notify();
if (!buffer_full) {
- fprintf(stderr, "ZeroMQ buffer overfull !\n");
+ etiLog.level(warn) << "ZeroMQ buffer overfull !";
buffer_full = true;
throw std::runtime_error("ZMQ input full");
@@ -195,18 +193,17 @@ void InputZeroMQWorker::RecvProcess(struct InputZeroMQThreadData* workerdata)
}
if (queue_size < 5) {
- fprintf(stderr, "ZeroMQ buffer low: %zu elements !\n",
- queue_size);
+ etiLog.level(warn) << "ZeroMQ buffer low: " << queue_size << "elements !";
}
}
}
catch (zmq::error_t& err) {
- fprintf(stderr, "ZeroMQ error in RecvProcess: '%s'\n", err.what());
+ etiLog.level(error) << "ZeroMQ error in RecvProcess: '" << err.what() << "'";
}
catch (std::exception& err) {
}
- fprintf(stderr, "ZeroMQ input worker terminated\n");
+ etiLog.level(info) << "ZeroMQ input worker terminated";
subscriber.close();
diff --git a/src/Log.cpp b/src/Log.cpp
index 9b7a2c3..0464137 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -73,8 +73,6 @@ void Logger::logstr(log_level_t level, std::string message)
++it) {
(*it)->log(level, message);
}
-
- std::cerr << levels_as_str[level] << " " << message << std::endl;
}
diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp
index a817abb..28df515 100644
--- a/src/OutputUHD.cpp
+++ b/src/OutputUHD.cpp
@@ -53,19 +53,17 @@ typedef std::complex<float> complexf;
void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg)
{
if (type == uhd::msg::warning) {
- std::cerr << "UHD Warning: " << msg << std::endl;
+ etiLog.level(warn) << "UHD Warning: " << msg;
}
else if (type == uhd::msg::error) {
- std::cerr << "UHD Error: " << msg << std::endl;
+ etiLog.level(error) << "UHD Error: " << msg;
}
}
OutputUHD::OutputUHD(
- const OutputUHDConfig& config,
- Logger *logger) :
+ const OutputUHDConfig& config) :
ModOutput(ModFormat(1), ModFormat(0)),
RemoteControllable("uhd"),
- myLogger(logger),
myConf(config),
// Since we don't know the buffer size, we cannot initialise
// the buffers at object initialisation.
@@ -170,18 +168,18 @@ OutputUHD::OutputUHD(
myConf.muteNoTimestamps ? "enabled" : "disabled");
if (myConf.enableSync && (myConf.pps_src == "none")) {
- myLogger->level(warn) <<
+ etiLog.level(warn) <<
"OutputUHD: WARNING:"
" you are using synchronous transmission without PPS input!";
struct timespec now;
if (clock_gettime(CLOCK_REALTIME, &now)) {
perror("OutputUHD:Error: could not get time: ");
- myLogger->level(error) << "OutputUHD: could not get time";
+ etiLog.level(error) << "OutputUHD: could not get time";
}
else {
myUsrp->set_time_now(uhd::time_spec_t(now.tv_sec));
- myLogger->level(info) << "OutputUHD: Setting USRP time to " <<
+ etiLog.level(info) << "OutputUHD: Setting USRP time to " <<
uhd::time_spec_t(now.tv_sec).get_real_secs();
}
}
@@ -192,7 +190,7 @@ OutputUHD::OutputUHD(
struct timespec now;
time_t seconds;
if (clock_gettime(CLOCK_REALTIME, &now)) {
- myLogger->level(error) << "OutputUHD: could not get time :" <<
+ etiLog.level(error) << "OutputUHD: could not get time :" <<
strerror(errno);
throw std::runtime_error("OutputUHD: could not get time.");
}
@@ -203,7 +201,7 @@ OutputUHD::OutputUHD(
while (seconds + 1 > now.tv_sec) {
usleep(1);
if (clock_gettime(CLOCK_REALTIME, &now)) {
- myLogger->level(error) << "OutputUHD: could not get time :" <<
+ etiLog.level(error) << "OutputUHD: could not get time :" <<
strerror(errno);
throw std::runtime_error("OutputUHD: could not get time.");
}
@@ -213,12 +211,12 @@ OutputUHD::OutputUHD(
usleep(200000); // 200ms, we want the PPS to be later
myUsrp->set_time_unknown_pps(uhd::time_spec_t(seconds + 2));
- myLogger->level(info) << "OutputUHD: Setting USRP time next pps to " <<
+ etiLog.level(info) << "OutputUHD: Setting USRP time next pps to " <<
uhd::time_spec_t(seconds + 2).get_real_secs();
}
usleep(1e6);
- myLogger->log(info, "OutputUHD: USRP time %f\n",
+ etiLog.log(info, "OutputUHD: USRP time %f\n",
myUsrp->get_time_now().get_real_secs());
}
@@ -232,7 +230,6 @@ OutputUHD::OutputUHD(
uwd.sampleRate = myConf.sampleRate;
uwd.sourceContainsTimestamp = false;
uwd.muteNoTimestamps = myConf.muteNoTimestamps;
- uwd.logger = myLogger;
uwd.refclk_lock_loss_behaviour = myConf.refclk_lock_loss_behaviour;
if (myConf.refclk_src == "internal") {
@@ -310,7 +307,7 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut)
// We will only wait on the barrier on the subsequent calls to
// OutputUHD::process
if (first_run) {
- myLogger->level(debug) << "OutputUHD: UHD initialising...";
+ etiLog.level(debug) << "OutputUHD: UHD initialising...";
worker.start(&uwd);
@@ -345,13 +342,13 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut)
lastLen = uwd.bufsize;
first_run = false;
- myLogger->level(debug) << "OutputUHD: UHD initialising complete";
+ etiLog.level(debug) << "OutputUHD: UHD initialising complete";
}
else {
if (lastLen != dataIn->getLength()) {
// I expect that this never happens.
- myLogger->level(emerg) <<
+ etiLog.level(emerg) <<
"OutputUHD: Fatal error, input length changed from " << lastLen <<
" to " << dataIn->getLength();
throw std::runtime_error("Non-constant input length!");
@@ -365,7 +362,7 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut)
throw fct_discontinuity_error();
}
else {
- myLogger->level(error) <<
+ etiLog.level(error) <<
"OutputUHD: Error, UHD worker failed";
throw std::runtime_error("UHD worker failed");
}
@@ -419,13 +416,13 @@ void UHDWorker::process_errhandler()
process();
}
catch (fct_discontinuity_error& e) {
- uwd->logger->level(warn) << e.what();
+ etiLog.level(warn) << e.what();
uwd->failed_due_to_fct = true;
}
uwd->running = false;
uwd->sync_barrier.get()->wait();
- uwd->logger->level(warn) << "UHD worker terminated";
+ etiLog.level(warn) << "UHD worker terminated";
}
// Check function for GPS fixtype
@@ -436,7 +433,7 @@ bool check_gps_fix_ok(struct UHDWorkerData *uwd)
uwd->myUsrp->get_mboard_sensor("gps_fixtype", 0).to_pp_string());
if (fixtype.find("3d fix") == std::string::npos) {
- uwd->logger->level(warn) << "OutputUHD: " << fixtype;
+ etiLog.level(warn) << "OutputUHD: " << fixtype;
return false;
}
@@ -444,7 +441,7 @@ bool check_gps_fix_ok(struct UHDWorkerData *uwd)
return true;
}
catch (uhd::lookup_error &e) {
- uwd->logger->level(warn) << "OutputUHD: no gps_fixtype sensor";
+ etiLog.level(warn) << "OutputUHD: no gps_fixtype sensor";
return false;
}
}
@@ -531,13 +528,13 @@ void UHDWorker::process()
* frame we must interrupt UHD and resync to the timestamps
*/
if (frame->ts.fct == -1) {
- uwd->logger->level(info) <<
+ etiLog.level(info) <<
"OutputUHD: dropping one frame with invalid FCT";
goto loopend;
}
if (expected_next_fct != -1) {
if (expected_next_fct != (int)frame->ts.fct) {
- uwd->logger->level(warn) <<
+ etiLog.level(warn) <<
"OutputUHD: Incorrect expect fct " << frame->ts.fct <<
", expected " << expected_next_fct;
@@ -553,7 +550,7 @@ void UHDWorker::process()
try {
// TODO: Is this check specific to the B100 and USRP2 ?
if (! uwd->myUsrp->get_mboard_sensor("ref_locked", 0).to_bool()) {
- uwd->logger->log(alert,
+ etiLog.log(alert,
"OutputUHD: External reference clock lock lost !");
if (uwd->refclk_lock_loss_behaviour == CRASH) {
throw std::runtime_error(
@@ -563,7 +560,7 @@ void UHDWorker::process()
}
catch (uhd::lookup_error &e) {
uwd->check_refclk_loss = false;
- uwd->logger->log(warn,
+ etiLog.log(warn,
"OutputUHD: This USRP does not have mboard sensor for ext clock loss."
" Check disabled.");
}
@@ -588,14 +585,14 @@ void UHDWorker::process()
if (not gps_fix_future.get()) {
if (not num_checks_without_gps_fix) {
- uwd->logger->level(alert) <<
+ etiLog.level(alert) <<
"OutputUHD: GPS Fix lost";
}
num_checks_without_gps_fix++;
}
else {
if (num_checks_without_gps_fix) {
- uwd->logger->level(info) <<
+ etiLog.level(info) <<
"OutputUHD: GPS Fix recovered";
}
num_checks_without_gps_fix = 0;
@@ -628,7 +625,7 @@ void UHDWorker::process()
/* We have not received a full timestamp through
* MNSC. We sleep through the frame.
*/
- uwd->logger->level(info) <<
+ etiLog.level(info) <<
"OutputUHD: Throwing sample " << frame->ts.fct <<
" away: incomplete timestamp " << tx_second <<
" + " << pps_offset;
@@ -641,7 +638,7 @@ void UHDWorker::process()
// md is defined, let's do some checks
if (md.time_spec.get_real_secs() + timeout < usrp_time) {
- uwd->logger->level(warn) <<
+ etiLog.level(warn) <<
"OutputUHD: Timestamp in the past! offset: " <<
md.time_spec.get_real_secs() - usrp_time <<
" (" << usrp_time << ")"
@@ -653,7 +650,7 @@ void UHDWorker::process()
#if 0 // Let uhd handle this
if (md.time_spec.get_real_secs() > usrp_time + TIMESTAMP_MARGIN_FUTURE) {
- uwd->logger->level(warn) <<
+ etiLog.level(warn) <<
"OutputUHD: Timestamp too far in the future! offset: " <<
md.time_spec.get_real_secs() - usrp_time;
usleep(20000); //sleep so as to fill buffers
@@ -661,7 +658,7 @@ void UHDWorker::process()
#endif
if (md.time_spec.get_real_secs() > usrp_time + TIMESTAMP_ABORT_FUTURE) {
- uwd->logger->level(error) <<
+ etiLog.level(error) <<
"OutputUHD: Timestamp way too far in the future! offset: " <<
md.time_spec.get_real_secs() - usrp_time;
throw std::runtime_error("Timestamp error. Aborted.");
@@ -672,12 +669,12 @@ void UHDWorker::process()
/* There was some error decoding the timestamp
*/
if (uwd->muting) {
- uwd->logger->log(info,
+ etiLog.log(info,
"OutputUHD: Muting sample %d requested\n",
frame->ts.fct);
}
else {
- uwd->logger->log(info,
+ etiLog.log(info,
"OutputUHD: Muting sample %d : no timestamp\n",
frame->ts.fct);
}
@@ -728,7 +725,7 @@ void UHDWorker::process()
if (num_tx_samps == 0) {
#if 1
- uwd->logger->log(warn,
+ etiLog.log(warn,
"UHDWorker::process() unable to write to device, skipping frame!\n");
break;
#else
@@ -791,9 +788,9 @@ void UHDWorker::process()
}
if (failure) {
- uwd->logger->level(alert) << "Near frame " <<
- frame->ts.fct << ": Received Async UHD Message '" <<
- uhd_async_message << "'";
+ etiLog.level(alert) << "Near frame " <<
+ frame->ts.fct << ": Received Async UHD Message '" <<
+ uhd_async_message << "'";
}
}
@@ -802,7 +799,7 @@ void UHDWorker::process()
if (last_pps > pps_offset) {
if (num_underflows or num_late_packets) {
- uwd->logger->log(info,
+ etiLog.log(info,
"OutputUHD status (usrp time: %f): "
"%d underruns and %d late packets since last status.\n",
usrp_time,
@@ -890,3 +887,4 @@ const string OutputUHD::get_parameter(const string& parameter) const
}
#endif // HAVE_OUTPUT_UHD
+
diff --git a/src/OutputUHD.h b/src/OutputUHD.h
index 2017f60..44dd0ff 100644
--- a/src/OutputUHD.h
+++ b/src/OutputUHD.h
@@ -136,9 +136,6 @@ struct UHDWorkerData {
// What to do when the reference clock PLL loses lock
refclk_lock_loss_behaviour_t refclk_lock_loss_behaviour;
- // The common logger
- Logger* logger;
-
// What transmission mode we're using defines by how
// much the FCT should increment for each
// transmission frame.
@@ -207,9 +204,7 @@ struct OutputUHDConfig {
class OutputUHD: public ModOutput, public RemoteControllable {
public:
- OutputUHD(
- const OutputUHDConfig& config,
- Logger *logger);
+ OutputUHD(const OutputUHDConfig& config);
~OutputUHD();
int process(Buffer* dataIn, Buffer* dataOut);
@@ -235,7 +230,9 @@ class OutputUHD: public ModOutput, public RemoteControllable {
protected:
- Logger *myLogger;
+ OutputUHD(const OutputUHD& other);
+ OutputUHD& operator=(const OutputUHD& other);
+
EtiReader *myEtiReader;
OutputUHDConfig myConf;
uhd::usrp::multi_usrp::sptr myUsrp;
diff --git a/src/RemoteControl.h b/src/RemoteControl.h
index 15b35f6..8f4bdaf 100644
--- a/src/RemoteControl.h
+++ b/src/RemoteControl.h
@@ -50,6 +50,7 @@
#include <boost/thread.hpp>
#include <stdexcept>
+#include "Log.h"
#define RC_ADD_PARAMETER(p, desc) { \
std::vector<std::string> p; \
@@ -114,8 +115,8 @@ class RemoteControllers {
it != m_controllers.end(); ++it) {
if ((*it)->fault_detected())
{
- fprintf(stderr,
- "Detected Remote Control fault, restarting it\n");
+ etiLog.level(warn) <<
+ "Detected Remote Control fault, restarting it";
(*it)->restart();
}
}
diff --git a/src/TimestampDecoder.cpp b/src/TimestampDecoder.cpp
index 6063048..c833e7a 100644
--- a/src/TimestampDecoder.cpp
+++ b/src/TimestampDecoder.cpp
@@ -96,7 +96,7 @@ void TimestampDecoder::calculateTimestamp(struct frame_timestamp& ts)
modconfig.delay_calculation_pipeline_stages);
if (queue_timestamps.size() > modconfig.delay_calculation_pipeline_stages) {
- myLogger.level(error) << "Error: Timestamp queue is too large : size " <<
+ etiLog.level(error) << "Error: Timestamp queue is too large : size " <<
queue_timestamps.size() << "! This should not happen !";
}
@@ -231,7 +231,7 @@ bool TimestampDecoder::updateModulatorOffset()
}
catch (bad_lexical_cast& e)
{
- myLogger.level(error) <<
+ etiLog.level(error) <<
"Error parsing timestamp offset from file '" <<
modconfig.offset_filename << "'";
r = false;
@@ -239,7 +239,7 @@ bool TimestampDecoder::updateModulatorOffset()
}
else
{
- myLogger.level(error) <<
+ etiLog.level(error) <<
"Error reading from timestamp offset file: eof reached\n";
r = false;
}
@@ -247,7 +247,7 @@ bool TimestampDecoder::updateModulatorOffset()
}
catch (exception& e)
{
- myLogger.level(error) << "Error opening timestamp offset file\n";
+ etiLog.level(error) << "Error opening timestamp offset file\n";
r = false;
}
@@ -257,7 +257,7 @@ bool TimestampDecoder::updateModulatorOffset()
if (timestamp_offset != newoffset)
{
timestamp_offset = newoffset;
- myLogger.level(info) <<
+ etiLog.level(info) <<
"TimestampDecoder::updateTimestampOffset: new offset is " <<
timestamp_offset;
offset_changed = true;
diff --git a/src/TimestampDecoder.h b/src/TimestampDecoder.h
index 8c6b362..82753d1 100644
--- a/src/TimestampDecoder.h
+++ b/src/TimestampDecoder.h
@@ -113,9 +113,8 @@ class TimestampDecoder
{
public:
TimestampDecoder(
- struct modulator_offset_config& config,
- Logger& logger):
- myLogger(logger), modconfig(config)
+ struct modulator_offset_config& config) :
+ modconfig(config)
{
inhibit_second_update = 0;
time_pps = 0.0;
@@ -126,8 +125,8 @@ class TimestampDecoder
gmtime_r(0, &temp_time);
offset_changed = false;
- myLogger.level(info) << "Setting up timestamp decoder with " <<
- (modconfig.use_offset_fixed ? "fixed" :
+ etiLog.level(info) << "Setting up timestamp decoder with " <<
+ (modconfig.use_offset_fixed ? "fixed" :
(modconfig.use_offset_file ? "dynamic" : "none")) <<
" offset";
@@ -148,9 +147,6 @@ class TimestampDecoder
bool updateModulatorOffset();
protected:
- /* Main program logger */
- Logger& myLogger;
-
/* Push a new MNSC field into the decoder */
void pushMNSCData(int framephase, uint16_t mnsc);