mirror of
https://github.com/YACReader/yacreader
synced 2025-07-24 16:05:01 -04:00
fixed YACReader <-> YACReaderLibrary communication
updated QsLog sources
This commit is contained in:
@ -31,7 +31,7 @@
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
|
||||
#define QS_LOG_VERSION "2.0b1"
|
||||
#define QS_LOG_VERSION "2.0b3"
|
||||
|
||||
namespace QsLogging
|
||||
{
|
||||
@ -56,7 +56,7 @@ public:
|
||||
|
||||
//! The helper forwards the streaming to QDebug and builds the final
|
||||
//! log message.
|
||||
class Helper
|
||||
class QSLOG_SHARED_OBJECT Helper
|
||||
{
|
||||
public:
|
||||
explicit Helper(Level logLevel) :
|
||||
|
@ -2,18 +2,22 @@ INCLUDEPATH += $$PWD
|
||||
#DEFINES += QS_LOG_LINE_NUMBERS # automatically writes the file and line for each log message
|
||||
#DEFINES += QS_LOG_DISABLE # logging code is replaced with a no-op
|
||||
DEFINES += QS_LOG_SEPARATE_THREAD # messages are queued and written from a separate thread
|
||||
|
||||
SOURCES += $$PWD/QsLogDest.cpp \
|
||||
$$PWD/QsLog.cpp \
|
||||
$$PWD/QsLogDestConsole.cpp \
|
||||
$$PWD/QsLogDestFile.cpp
|
||||
$$PWD/QsLogDestFile.cpp \
|
||||
$$PWD/QsLogDestFunctor.cpp
|
||||
|
||||
HEADERS += $$PWD/QSLogDest.h \
|
||||
$$PWD/QsLog.h \
|
||||
$$PWD/QsLogDestConsole.h \
|
||||
$$PWD/QsLogLevel.h \
|
||||
$$PWD/QsLogDestFile.h \
|
||||
$$PWD/QsLogDisableForThisFile.h
|
||||
$$PWD/QsLogDisableForThisFile.h \
|
||||
$$PWD/QsLogDestFunctor.h
|
||||
|
||||
OTHER_FILES += \
|
||||
$$PWD/QsLogChanges.txt \
|
||||
$$PWD/QsLogReadme.txt
|
||||
$$PWD/QsLogReadme.txt \
|
||||
$$PWD/LICENSE.txt
|
||||
|
@ -26,11 +26,16 @@
|
||||
#include "QsLogDest.h"
|
||||
#include "QsLogDestConsole.h"
|
||||
#include "QsLogDestFile.h"
|
||||
#include "QsLogDestFunctor.h"
|
||||
#include <QString>
|
||||
|
||||
namespace QsLogging
|
||||
{
|
||||
|
||||
Destination::~Destination()
|
||||
{
|
||||
}
|
||||
|
||||
//! destination factory
|
||||
DestinationPtr DestinationFactory::MakeFileDestination(const QString& filePath,
|
||||
LogRotationOption rotation, const MaxSizeBytes &sizeInBytesToRotateAfter,
|
||||
@ -52,4 +57,14 @@ DestinationPtr DestinationFactory::MakeDebugOutputDestination()
|
||||
return DestinationPtr(new DebugOutputDestination);
|
||||
}
|
||||
|
||||
DestinationPtr DestinationFactory::MakeFunctorDestination(QsLogging::Destination::LogFunction f)
|
||||
{
|
||||
return DestinationPtr(new FunctorDestination(f));
|
||||
}
|
||||
|
||||
DestinationPtr DestinationFactory::MakeFunctorDestination(QObject *receiver, const char *member)
|
||||
{
|
||||
return DestinationPtr(new FunctorDestination(receiver, member));
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
@ -30,11 +30,14 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QtGlobal>
|
||||
class QString;
|
||||
class QObject;
|
||||
|
||||
#ifdef QSLOG_IS_SHARED_LIBRARY
|
||||
#define QSLOG_SHARED_OBJECT Q_DECL_EXPORT
|
||||
#elif QSLOG_IS_SHARED_LIBRARY_IMPORT
|
||||
#define QSLOG_SHARED_OBJECT Q_DECL_IMPORT
|
||||
#else
|
||||
#define QSLOG_SHARED_OBJECT /*Q_DECL_IMPORT*/
|
||||
#define QSLOG_SHARED_OBJECT
|
||||
#endif
|
||||
|
||||
namespace QsLogging
|
||||
@ -43,7 +46,10 @@ namespace QsLogging
|
||||
class QSLOG_SHARED_OBJECT Destination
|
||||
{
|
||||
public:
|
||||
virtual ~Destination(){}
|
||||
typedef void (*LogFunction)(const QString &message, Level level);
|
||||
|
||||
public:
|
||||
virtual ~Destination();
|
||||
virtual void write(const QString& message, Level level) = 0;
|
||||
virtual bool isValid() = 0; // returns whether the destination was created correctly
|
||||
};
|
||||
@ -60,14 +66,14 @@ enum LogRotationOption
|
||||
struct QSLOG_SHARED_OBJECT MaxSizeBytes
|
||||
{
|
||||
MaxSizeBytes() : size(0) {}
|
||||
MaxSizeBytes(qint64 size_) : size(size_) {}
|
||||
explicit MaxSizeBytes(qint64 size_) : size(size_) {}
|
||||
qint64 size;
|
||||
};
|
||||
|
||||
struct QSLOG_SHARED_OBJECT MaxOldLogCount
|
||||
{
|
||||
MaxOldLogCount() : count(0) {}
|
||||
MaxOldLogCount(int count_) : count(count_) {}
|
||||
explicit MaxOldLogCount(int count_) : count(count_) {}
|
||||
int count;
|
||||
};
|
||||
|
||||
@ -82,6 +88,10 @@ public:
|
||||
const MaxSizeBytes &sizeInBytesToRotateAfter = MaxSizeBytes(),
|
||||
const MaxOldLogCount &oldLogsToKeep = MaxOldLogCount());
|
||||
static DestinationPtr MakeDebugOutputDestination();
|
||||
// takes a pointer to a function
|
||||
static DestinationPtr MakeFunctorDestination(Destination::LogFunction f);
|
||||
// takes a QObject + signal/slot
|
||||
static DestinationPtr MakeFunctorDestination(QObject *receiver, const char *member);
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
|
57
QsLog/QsLogDestFunctor.cpp
Normal file
57
QsLog/QsLogDestFunctor.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2014, Razvan Petru
|
||||
// Copyright (c) 2014, Omar Carey
|
||||
// All rights reserved.
|
||||
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
|
||||
// * Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
// list of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
// * The name of the contributors may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "QsLogDestFunctor.h"
|
||||
#include <cstddef>
|
||||
#include <QtGlobal>
|
||||
|
||||
QsLogging::FunctorDestination::FunctorDestination(LogFunction f)
|
||||
: QObject(NULL)
|
||||
, mLogFunction(f)
|
||||
{
|
||||
}
|
||||
|
||||
QsLogging::FunctorDestination::FunctorDestination(QObject *receiver, const char *member)
|
||||
: QObject(NULL)
|
||||
, mLogFunction(NULL)
|
||||
{
|
||||
connect(this, SIGNAL(logMessageReady(QString,int)), receiver, member, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
|
||||
void QsLogging::FunctorDestination::write(const QString &message, QsLogging::Level level)
|
||||
{
|
||||
if (mLogFunction)
|
||||
mLogFunction(message, level);
|
||||
|
||||
if (level > QsLogging::TraceLevel)
|
||||
emit logMessageReady(message, static_cast<int>(level));
|
||||
}
|
||||
|
||||
bool QsLogging::FunctorDestination::isValid()
|
||||
{
|
||||
return true;
|
||||
}
|
59
QsLog/QsLogDestFunctor.h
Normal file
59
QsLog/QsLogDestFunctor.h
Normal file
@ -0,0 +1,59 @@
|
||||
// Copyright (c) 2014, Razvan Petru
|
||||
// Copyright (c) 2014, Omar Carey
|
||||
// All rights reserved.
|
||||
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
|
||||
// * Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
// list of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
// * The name of the contributors may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef QSLOGDESTFUNCTOR_H
|
||||
#define QSLOGDESTFUNCTOR_H
|
||||
|
||||
#include "QSLogDest.h"
|
||||
#include <QObject>
|
||||
|
||||
namespace QsLogging
|
||||
{
|
||||
// Offers various types of function-like sinks.
|
||||
// This is an advanced destination type. Depending on your configuration, LogFunction might be
|
||||
// called from a different thread or even a different binary. You should not access QsLog from
|
||||
// inside LogFunction and should not perform any time-consuming operations.
|
||||
// logMessageReady is connected through a queued connection and trace messages are not included
|
||||
class FunctorDestination : public QObject, public Destination
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FunctorDestination(LogFunction f);
|
||||
FunctorDestination(QObject *receiver, const char *member);
|
||||
|
||||
virtual void write(const QString &message, Level level);
|
||||
virtual bool isValid();
|
||||
|
||||
protected:
|
||||
// int used to avoid registering a new enum type
|
||||
Q_SIGNAL void logMessageReady(const QString &message, int level);
|
||||
|
||||
private:
|
||||
LogFunction mLogFunction;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // QSLOGDESTFUNCTOR_H
|
@ -11,6 +11,11 @@ TEMPLATE = lib
|
||||
|
||||
DESTDIR = $$PWD/build-QsLogShared
|
||||
OBJECTS_DIR = $$DESTDIR/obj
|
||||
MOC_DIR = $$DESTDIR/moc
|
||||
|
||||
win32 {
|
||||
DEFINES += QSLOG_IS_SHARED_LIBRARY
|
||||
}
|
||||
|
||||
unix:!macx {
|
||||
# make install will install the shared object in the appropriate folders
|
||||
|
Reference in New Issue
Block a user