0

We are building a module that is part of a full embedded Linux operating systems. We are using log4cplus for diagnostics.

log.properties contains:

log4cplus.logger.CompanyGlue=TRACE, console

cm_bind_helper.h contains much more complicated than this. All of the DBG_XXX messages appear on the console.

#include "qobject.h"
#include "log4cplus/dbglog.h"
class bind_helper : public QObject
{
protected:
    const char *debugModuleName = "CompanyGlue";
    log4cplus::Logger debugModule { Logger::getInstance(debugModuleName) };

    bool set_value(CMPath path, PType &input)
    {
        auto old_value = CMRoot()->getValue(path);
        if (input != old_value) {
            DBG_DEBUG("Changing " << path << " to " << input);
        }
    }
}

cm_bridge.cpp contains much more code than this. However, none of the DBG_XXX messages appear on the console.

#include "cm_bridge.h"
#include "cm_bind_helpers.h"

struct CompanyContentModelBridge::detail_ : public bind_helper
{
    std::shared_ptr<company::device_base> base;

    detail_(QObject *parent)
        : bind_helper(parent)
    {
        configure_system_advanced_control();
    }
    void configure_system_advanced_control();
    std::string get_exported_file_size();
}

using detail_ = CompanyContentModelBridge::detail_;

void detail_::configure_system_advanced_control()
{
    base->add_get_only_entry<std::string>("SPDSZ", get_exported_file_size());
}

std::string detail_::get_exported_file_size()
{
    DBG_INFO("get exported file size");
    //diag("exported file size");
}

I have tried various ways to configure log4cplus in cm_bridge.cpp, including the same two lines in cm_bind_helpers.h and as follows. I also removed them assuming that inheritance would handle it. Nothing made the DBG_XXX messages appear.

DBG_IMPL_DEBUG_MODULE(CompanyGlue);

Eventually, I added this function to cm_bind_helpers.h. It worked when called from its own class but failed when called from get_exported_file_size() (with comment removed).

void diag(std::string_view what) {
    DBG_DEBUG("bind helper diag " << what);
}

I'm stumped. I do not know why messages are being suppressed from one file but not the other.

cigien
  • 57,834
  • 11
  • 73
  • 112
J-A-Brown
  • 85
  • 1
  • 3
  • 9

0 Answers0