[muscle] Using muscle::PutLogCallback

  • From: Raymond Dahlberg <rd@xxxxxxxxxxx>
  • To: muscle@xxxxxxxxxxxxx
  • Date: Wed, 28 Apr 2010 14:54:57 +0200

Hi.

I want to use the muscle::PutLogCallback method to add a custom log handler
that is integrated with Qt, so that I can post log messages in a Qt GUI.

For this I have created a class that inherits from LogLineCallback and
QObject so that it can emit a Qt signal when a new logLine is ready, class
declaration like this:

#ifndef MUSCLELOGCALLBACK_H
#define MUSCLELOGCALLBACK_H

#include <syslog/LogCallback.h>
#include <QObject>

using namespace muscle;

class MuscleLogCallback : public QObject, public LogLineCallback
{
Q_OBJECT
public:
    MuscleLogCallback(QObject *parent = 0);

signals:
    void logLine(const QString& message);

protected:
    virtual void LogLine(const LogCallbackArgs& a);

};

#endif // MUSCLELOGCALLBACK_H

I have an instance of this class in my main GUI class, where I try to add it
to the logging system with PutLogCallback, - but this method need a const
LogCallbackRef& as input parameter. But I have the log class as an member
declared like this:

private:
    Ui::TestServer *ui;
    MuscleLogCallback _muscleLogger;

And in the constructor of the GUI class I try to do:

    muscle::PutLogCallback(_muscleLogger);

But this does not compile: error C2664: 'muscle::PutLogCallback' : cannot
convert parameter 1 from 'MuscleLogCallback' to 'const
muscle::LogCallbackRef &'

So, how can I get a LogCallbackRef from a class that inherits from
LogLineCallback?`

/Raymond

Other related posts: