mirror of
https://github.com/jellyfin/jellyfin-media-player.git
synced 2024-11-22 21:49:56 +00:00
Switch from QsLog to regular QT logging.
This commit is contained in:
parent
9fd786fdc0
commit
721e84f5b4
50
.vscode/settings.json
vendored
50
.vscode/settings.json
vendored
@ -20,6 +20,54 @@
|
||||
"ostream": "cpp",
|
||||
"ratio": "cpp",
|
||||
"functional": "cpp",
|
||||
"type_traits": "cpp"
|
||||
"type_traits": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"bitset": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"compare": "cpp",
|
||||
"complex": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"random": "cpp",
|
||||
"source_location": "cpp",
|
||||
"string_view": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"ranges": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"__nullptr": "cpp"
|
||||
}
|
||||
}
|
2
external/CMakeLists.txt
vendored
2
external/CMakeLists.txt
vendored
@ -1,8 +1,6 @@
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS_THIRD_PARTY}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS_THIRD_PARTY}")
|
||||
|
||||
add_subdirectory(qslog)
|
||||
|
||||
if(APPLE)
|
||||
add_subdirectory(plistparser)
|
||||
add_subdirectory(SPMediaKeyTap)
|
||||
|
4
external/qslog/CMakeLists.txt
vendored
4
external/qslog/CMakeLists.txt
vendored
@ -1,4 +0,0 @@
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
aux_source_directory(. QSLOG_SRC)
|
||||
add_library(qslog STATIC ${QSLOG_SRC})
|
||||
std_target_properties(qslog)
|
24
external/qslog/LICENSE.txt
vendored
24
external/qslog/LICENSE.txt
vendored
@ -1,24 +0,0 @@
|
||||
Copyright (c) 2014, Razvan Petru
|
||||
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.
|
259
external/qslog/QsLog.cpp
vendored
259
external/qslog/QsLog.cpp
vendored
@ -1,259 +0,0 @@
|
||||
// Copyright (c) 2013, Razvan Petru
|
||||
// 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 "QsLog.h"
|
||||
#include "QsLogDest.h"
|
||||
#ifdef QS_LOG_SEPARATE_THREAD
|
||||
#include <QThreadPool>
|
||||
#include <QRunnable>
|
||||
#endif
|
||||
#include <QMutex>
|
||||
#include <QVector>
|
||||
#include <QDateTime>
|
||||
#include <QtGlobal>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace QsLogging
|
||||
{
|
||||
typedef QVector<DestinationPtr> DestinationList;
|
||||
|
||||
static const char TraceString[] = "TRACE";
|
||||
static const char DebugString[] = "DEBUG";
|
||||
static const char InfoString[] = "INFO ";
|
||||
static const char WarnString[] = "WARN ";
|
||||
static const char ErrorString[] = "ERROR";
|
||||
static const char FatalString[] = "FATAL";
|
||||
|
||||
// not using Qt::ISODate because we need the milliseconds too
|
||||
static const QString fmtDateTime("yyyy-MM-dd hh:mm:ss");
|
||||
|
||||
static Logger* sInstance = 0;
|
||||
|
||||
static const char* LevelToText(Level theLevel)
|
||||
{
|
||||
switch (theLevel) {
|
||||
case TraceLevel:
|
||||
return TraceString;
|
||||
case DebugLevel:
|
||||
return DebugString;
|
||||
case InfoLevel:
|
||||
return InfoString;
|
||||
case WarnLevel:
|
||||
return WarnString;
|
||||
case ErrorLevel:
|
||||
return ErrorString;
|
||||
case FatalLevel:
|
||||
return FatalString;
|
||||
case OffLevel:
|
||||
return "";
|
||||
default: {
|
||||
assert(!"bad log level");
|
||||
return InfoString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef QS_LOG_SEPARATE_THREAD
|
||||
class LogWriterRunnable : public QRunnable
|
||||
{
|
||||
public:
|
||||
LogWriterRunnable(QString message, Level level);
|
||||
virtual void run();
|
||||
|
||||
private:
|
||||
QString mMessage;
|
||||
Level mLevel;
|
||||
};
|
||||
#endif
|
||||
|
||||
class LoggerImpl
|
||||
{
|
||||
public:
|
||||
LoggerImpl();
|
||||
|
||||
#ifdef QS_LOG_SEPARATE_THREAD
|
||||
QThreadPool threadPool;
|
||||
#endif
|
||||
QMutex logMutex;
|
||||
Level level;
|
||||
DestinationList destList;
|
||||
ProcessingCallback process;
|
||||
};
|
||||
|
||||
#ifdef QS_LOG_SEPARATE_THREAD
|
||||
LogWriterRunnable::LogWriterRunnable(QString message, Level level)
|
||||
: QRunnable()
|
||||
, mMessage(message)
|
||||
, mLevel(level)
|
||||
{
|
||||
}
|
||||
|
||||
void LogWriterRunnable::run()
|
||||
{
|
||||
Logger::instance().write(mMessage, mLevel);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
LoggerImpl::LoggerImpl()
|
||||
: level(InfoLevel)
|
||||
, process(0)
|
||||
{
|
||||
// assume at least file + console
|
||||
destList.reserve(2);
|
||||
#ifdef QS_LOG_SEPARATE_THREAD
|
||||
threadPool.setMaxThreadCount(1);
|
||||
threadPool.setExpiryTimeout(-1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Logger::Logger()
|
||||
: d(new LoggerImpl)
|
||||
{
|
||||
}
|
||||
|
||||
Logger& Logger::instance()
|
||||
{
|
||||
if (!sInstance)
|
||||
sInstance = new Logger;
|
||||
|
||||
return *sInstance;
|
||||
}
|
||||
|
||||
void Logger::destroyInstance()
|
||||
{
|
||||
delete sInstance;
|
||||
sInstance = 0;
|
||||
}
|
||||
|
||||
// tries to extract the level from a string log message. If available, conversionSucceeded will
|
||||
// contain the conversion result.
|
||||
Level Logger::levelFromLogMessage(const QString& logMessage, bool* conversionSucceeded)
|
||||
{
|
||||
if (conversionSucceeded)
|
||||
*conversionSucceeded = true;
|
||||
|
||||
if (logMessage.startsWith(QLatin1String(TraceString)))
|
||||
return TraceLevel;
|
||||
if (logMessage.startsWith(QLatin1String(DebugString)))
|
||||
return DebugLevel;
|
||||
if (logMessage.startsWith(QLatin1String(InfoString)))
|
||||
return InfoLevel;
|
||||
if (logMessage.startsWith(QLatin1String(WarnString)))
|
||||
return WarnLevel;
|
||||
if (logMessage.startsWith(QLatin1String(ErrorString)))
|
||||
return ErrorLevel;
|
||||
if (logMessage.startsWith(QLatin1String(FatalString)))
|
||||
return FatalLevel;
|
||||
|
||||
if (conversionSucceeded)
|
||||
*conversionSucceeded = false;
|
||||
return OffLevel;
|
||||
}
|
||||
|
||||
Logger::~Logger()
|
||||
{
|
||||
#ifdef QS_LOG_SEPARATE_THREAD
|
||||
d->threadPool.waitForDone();
|
||||
#endif
|
||||
delete d;
|
||||
d = 0;
|
||||
}
|
||||
|
||||
void Logger::addDestination(DestinationPtr destination)
|
||||
{
|
||||
QMutexLocker lock(&d->logMutex);
|
||||
assert(destination.data());
|
||||
d->destList.push_back(destination);
|
||||
}
|
||||
|
||||
void Logger::setLoggingLevel(Level newLevel)
|
||||
{
|
||||
d->level = newLevel;
|
||||
}
|
||||
|
||||
Level Logger::loggingLevel() const
|
||||
{
|
||||
return d->level;
|
||||
}
|
||||
|
||||
void Logger::setProcessingCallback(ProcessingCallback cb)
|
||||
{
|
||||
d->process = cb;
|
||||
}
|
||||
|
||||
//! creates the complete log message and passes it to the logger
|
||||
void Logger::Helper::writeToLog()
|
||||
{
|
||||
const char* const levelName = LevelToText(level);
|
||||
const QString completeMessage(QString("%1 [ %2 ] %3")
|
||||
.arg(QDateTime::currentDateTime().toString(fmtDateTime))
|
||||
.arg(levelName)
|
||||
.arg(buffer)
|
||||
);
|
||||
|
||||
Logger::instance().enqueueWrite(completeMessage, level);
|
||||
}
|
||||
|
||||
Logger::Helper::~Helper()
|
||||
{
|
||||
try {
|
||||
writeToLog();
|
||||
}
|
||||
catch(std::exception&) {
|
||||
// you shouldn't throw exceptions from a sink
|
||||
assert(!"exception in logger helper destructor");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//! directs the message to the task queue or writes it directly
|
||||
void Logger::enqueueWrite(QString message, Level level)
|
||||
{
|
||||
if (d->process)
|
||||
d->process(message);
|
||||
#ifdef QS_LOG_SEPARATE_THREAD
|
||||
LogWriterRunnable *r = new LogWriterRunnable(message, level);
|
||||
d->threadPool.start(r);
|
||||
#else
|
||||
write(message, level);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Sends the message to all the destinations. The level for this message is passed in case
|
||||
//! it's useful for processing in the destination.
|
||||
void Logger::write(const QString& message, Level level)
|
||||
{
|
||||
QMutexLocker lock(&d->logMutex);
|
||||
for (DestinationList::iterator it = d->destList.begin(),
|
||||
endIt = d->destList.end();it != endIt;++it) {
|
||||
(*it)->write(message, level);
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace
|
142
external/qslog/QsLog.h
vendored
142
external/qslog/QsLog.h
vendored
@ -1,142 +0,0 @@
|
||||
// Copyright (c) 2013, Razvan Petru
|
||||
// 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 QSLOG_H
|
||||
#define QSLOG_H
|
||||
|
||||
#include "QsLogLevel.h"
|
||||
#include "QsLogDest.h"
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
|
||||
#define QS_LOG_VERSION "2.0b3"
|
||||
|
||||
namespace QsLogging
|
||||
{
|
||||
class Destination;
|
||||
class LoggerImpl; // d pointer
|
||||
|
||||
typedef void (*ProcessingCallback)(QString& message);
|
||||
|
||||
class QSLOG_SHARED_OBJECT Logger
|
||||
{
|
||||
public:
|
||||
static Logger& instance();
|
||||
static void destroyInstance();
|
||||
static Level levelFromLogMessage(const QString& logMessage, bool* conversionSucceeded = 0);
|
||||
|
||||
~Logger();
|
||||
|
||||
//! Adds a log message destination. Don't add null destinations.
|
||||
void addDestination(DestinationPtr destination);
|
||||
//! Logging at a level < 'newLevel' will be ignored
|
||||
void setLoggingLevel(Level newLevel);
|
||||
//! The default level is INFO
|
||||
Level loggingLevel() const;
|
||||
//! Set callback for changing message contents before writing to output
|
||||
void setProcessingCallback(ProcessingCallback cb);
|
||||
|
||||
//! The helper forwards the streaming to QDebug and builds the final
|
||||
//! log message.
|
||||
class QSLOG_SHARED_OBJECT Helper
|
||||
{
|
||||
public:
|
||||
explicit Helper(Level logLevel) :
|
||||
level(logLevel),
|
||||
qtDebug(&buffer) {}
|
||||
~Helper();
|
||||
QDebug& stream(){ return qtDebug; }
|
||||
|
||||
private:
|
||||
void writeToLog();
|
||||
|
||||
Level level;
|
||||
QString buffer;
|
||||
QDebug qtDebug;
|
||||
};
|
||||
|
||||
private:
|
||||
Logger();
|
||||
Logger(const Logger&); // not available
|
||||
Logger& operator=(const Logger&); // not available
|
||||
|
||||
void enqueueWrite(QString message, Level level);
|
||||
void write(const QString& message, Level level);
|
||||
|
||||
LoggerImpl* d;
|
||||
|
||||
friend class LogWriterRunnable;
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
|
||||
//! Logging macros: define QS_LOG_LINE_NUMBERS to get the file and line number
|
||||
//! in the log output.
|
||||
#ifndef QS_LOG_LINE_NUMBERS
|
||||
#define QLOG_TRACE() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::TraceLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::TraceLevel).stream()
|
||||
#define QLOG_DEBUG() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::DebugLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::DebugLevel).stream()
|
||||
#define QLOG_INFO() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::InfoLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::InfoLevel).stream()
|
||||
#define QLOG_WARN() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::WarnLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::WarnLevel).stream()
|
||||
#define QLOG_ERROR() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::ErrorLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::ErrorLevel).stream()
|
||||
#define QLOG_FATAL() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::FatalLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::FatalLevel).stream()
|
||||
#else
|
||||
#define QLOG_TRACE() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::TraceLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::TraceLevel).stream() << qPrintable(QFileInfo(__FILE__).fileName()) << '@' << __LINE__ << "-"
|
||||
#define QLOG_DEBUG() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::DebugLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::DebugLevel).stream() << qPrintable(QFileInfo(__FILE__).fileName()) << '@' << __LINE__ << "-"
|
||||
#define QLOG_INFO() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::InfoLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::InfoLevel).stream() << qPrintable(QFileInfo(__FILE__).fileName()) << '@' << __LINE__ << "-"
|
||||
#define QLOG_WARN() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::WarnLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::WarnLevel).stream() << qPrintable(QFileInfo(__FILE__).fileName()) << '@' << __LINE__ << "-"
|
||||
#define QLOG_ERROR() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::ErrorLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::ErrorLevel).stream() << qPrintable(QFileInfo(__FILE__).fileName()) << '@' << __LINE__ << "-"
|
||||
#define QLOG_FATAL() \
|
||||
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::FatalLevel) {} \
|
||||
else QsLogging::Logger::Helper(QsLogging::FatalLevel).stream() << qPrintable(QFileInfo(__FILE__).fileName()) << '@' << __LINE__ << "-"
|
||||
#endif
|
||||
|
||||
#ifdef QS_LOG_DISABLE
|
||||
#include "QsLogDisableForThisFile.h"
|
||||
#endif
|
||||
|
||||
#endif // QSLOG_H
|
73
external/qslog/QsLogDest.cpp
vendored
73
external/qslog/QsLogDest.cpp
vendored
@ -1,73 +0,0 @@
|
||||
// Copyright (c) 2013, Razvan Petru
|
||||
// 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 "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,
|
||||
const MaxOldLogCount &oldLogsToKeep)
|
||||
{
|
||||
if (EnableLogRotation == rotation || EnableLogRotationOnOpen == rotation) {
|
||||
QScopedPointer<SizeRotationStrategy> logRotation(new SizeRotationStrategy);
|
||||
logRotation->setMaximumSizeInBytes(sizeInBytesToRotateAfter.size);
|
||||
logRotation->setBackupCount(oldLogsToKeep.count);
|
||||
|
||||
FileDestination *dest = new FileDestination(filePath, RotationStrategyPtr(logRotation.take()));
|
||||
if (EnableLogRotationOnOpen == rotation && dest->rotationStrategy()->currentSizeInBytes() > 0)
|
||||
dest->rotate();
|
||||
return DestinationPtr(dest);
|
||||
}
|
||||
|
||||
return DestinationPtr(new FileDestination(filePath, RotationStrategyPtr(new NullRotationStrategy)));
|
||||
}
|
||||
|
||||
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
|
101
external/qslog/QsLogDest.h
vendored
101
external/qslog/QsLogDest.h
vendored
@ -1,101 +0,0 @@
|
||||
// Copyright (c) 2013, Razvan Petru
|
||||
// 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 QSLOGDEST_H
|
||||
#define QSLOGDEST_H
|
||||
|
||||
#include "QsLogLevel.h"
|
||||
#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
|
||||
#endif
|
||||
|
||||
namespace QsLogging
|
||||
{
|
||||
|
||||
class QSLOG_SHARED_OBJECT Destination
|
||||
{
|
||||
public:
|
||||
typedef void (*LogFunction)(const QString &message, Level level);
|
||||
virtual void rotate() = 0;
|
||||
|
||||
public:
|
||||
virtual ~Destination();
|
||||
virtual void write(const QString& message, Level level) = 0;
|
||||
virtual bool isValid() = 0; // returns whether the destination was created correctly
|
||||
};
|
||||
typedef QSharedPointer<Destination> DestinationPtr;
|
||||
|
||||
|
||||
// a series of "named" paramaters, to make the file destination creation more readable
|
||||
enum LogRotationOption
|
||||
{
|
||||
DisableLogRotation = 0,
|
||||
EnableLogRotation = 1,
|
||||
EnableLogRotationOnOpen = 2,
|
||||
};
|
||||
|
||||
struct QSLOG_SHARED_OBJECT MaxSizeBytes
|
||||
{
|
||||
MaxSizeBytes() : size(0) {}
|
||||
explicit MaxSizeBytes(qint64 size_) : size(size_) {}
|
||||
qint64 size;
|
||||
};
|
||||
|
||||
struct QSLOG_SHARED_OBJECT MaxOldLogCount
|
||||
{
|
||||
MaxOldLogCount() : count(0) {}
|
||||
explicit MaxOldLogCount(int count_) : count(count_) {}
|
||||
int count;
|
||||
};
|
||||
|
||||
|
||||
//! Creates logging destinations/sinks. The caller shares ownership of the destinations with the logger.
|
||||
//! After being added to a logger, the caller can discard the pointers.
|
||||
class QSLOG_SHARED_OBJECT DestinationFactory
|
||||
{
|
||||
public:
|
||||
static DestinationPtr MakeFileDestination(const QString& filePath,
|
||||
LogRotationOption rotation = DisableLogRotation,
|
||||
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
|
||||
|
||||
#endif // QSLOGDEST_H
|
52
external/qslog/QsLogDestConsole.cpp
vendored
52
external/qslog/QsLogDestConsole.cpp
vendored
@ -1,52 +0,0 @@
|
||||
// Copyright (c) 2013, Razvan Petru
|
||||
// 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 "QsLogDestConsole.h"
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
void QsDebugOutput::output( const QString& message )
|
||||
{
|
||||
}
|
||||
#elif defined(Q_OS_UNIX)
|
||||
#include <cstdio>
|
||||
void QsDebugOutput::output( const QString& message )
|
||||
{
|
||||
fprintf(stderr, "%s\n", qPrintable(message));
|
||||
fflush(stderr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void QsLogging::DebugOutputDestination::write(const QString& message, Level)
|
||||
{
|
||||
QsDebugOutput::output(message);
|
||||
}
|
||||
|
||||
bool QsLogging::DebugOutputDestination::isValid()
|
||||
{
|
||||
return true;
|
||||
}
|
53
external/qslog/QsLogDestConsole.h
vendored
53
external/qslog/QsLogDestConsole.h
vendored
@ -1,53 +0,0 @@
|
||||
// Copyright (c) 2013, Razvan Petru
|
||||
// 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 QSLOGDESTCONSOLE_H
|
||||
#define QSLOGDESTCONSOLE_H
|
||||
|
||||
#include "QsLogDest.h"
|
||||
|
||||
class QString;
|
||||
|
||||
class QsDebugOutput
|
||||
{
|
||||
public:
|
||||
static void output(const QString& a_message);
|
||||
};
|
||||
|
||||
namespace QsLogging
|
||||
{
|
||||
|
||||
// debugger sink
|
||||
class DebugOutputDestination : public Destination
|
||||
{
|
||||
public:
|
||||
virtual void write(const QString& message, Level level);
|
||||
virtual bool isValid();
|
||||
virtual void rotate() { }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // QSLOGDESTCONSOLE_H
|
163
external/qslog/QsLogDestFile.cpp
vendored
163
external/qslog/QsLogDestFile.cpp
vendored
@ -1,163 +0,0 @@
|
||||
// Copyright (c) 2013, Razvan Petru
|
||||
// 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 "QsLogDestFile.h"
|
||||
#include <QTextCodec>
|
||||
#include <QDateTime>
|
||||
#include <QtGlobal>
|
||||
#include <iostream>
|
||||
|
||||
const int QsLogging::SizeRotationStrategy::MaxBackupCount = 10;
|
||||
|
||||
QsLogging::RotationStrategy::~RotationStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
QsLogging::SizeRotationStrategy::SizeRotationStrategy() : mCurrentSizeInBytes(0), mMaxSizeInBytes(0), mBackupsCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
void QsLogging::SizeRotationStrategy::setInitialInfo(const QFile& file)
|
||||
{
|
||||
mFileName = file.fileName();
|
||||
mCurrentSizeInBytes = file.size();
|
||||
}
|
||||
|
||||
void QsLogging::SizeRotationStrategy::includeMessageInCalculation(const QString& message)
|
||||
{
|
||||
mCurrentSizeInBytes += message.toUtf8().size();
|
||||
}
|
||||
|
||||
bool QsLogging::SizeRotationStrategy::shouldRotate()
|
||||
{
|
||||
return mCurrentSizeInBytes > mMaxSizeInBytes;
|
||||
}
|
||||
|
||||
// Algorithm assumes backups will be named filename.X, where 1 <= X <= mBackupsCount.
|
||||
// All X's will be shifted up.
|
||||
void QsLogging::SizeRotationStrategy::rotate()
|
||||
{
|
||||
if (!mBackupsCount)
|
||||
{
|
||||
if (!QFile::remove(mFileName))
|
||||
std::cerr << "QsLog: backup delete failed " << qPrintable(mFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. find the last existing backup than can be shifted up
|
||||
const QString logNamePattern = mFileName + QString::fromUtf8(".%1");
|
||||
int lastExistingBackupIndex = 0;
|
||||
for (int i = 1; i <= mBackupsCount; ++i)
|
||||
{
|
||||
const QString backupFileName = logNamePattern.arg(i);
|
||||
if (QFile::exists(backupFileName))
|
||||
lastExistingBackupIndex = qMin(i, mBackupsCount - 1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
// 2. shift up
|
||||
for (int i = lastExistingBackupIndex; i >= 1; --i)
|
||||
{
|
||||
const QString oldName = logNamePattern.arg(i);
|
||||
const QString newName = logNamePattern.arg(i + 1);
|
||||
QFile::remove(newName);
|
||||
const bool renamed = QFile::rename(oldName, newName);
|
||||
if (!renamed)
|
||||
{
|
||||
std::cerr << "QsLog: could not rename backup " << qPrintable(oldName) << " to " << qPrintable(newName);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. rename current log file
|
||||
const QString newName = logNamePattern.arg(1);
|
||||
if (QFile::exists(newName))
|
||||
QFile::remove(newName);
|
||||
if (!QFile::rename(mFileName, newName))
|
||||
{
|
||||
std::cerr << "QsLog: could not rename log " << qPrintable(mFileName) << " to " << qPrintable(newName);
|
||||
}
|
||||
}
|
||||
|
||||
QIODevice::OpenMode QsLogging::SizeRotationStrategy::recommendedOpenModeFlag()
|
||||
{
|
||||
return QIODevice::Append;
|
||||
}
|
||||
|
||||
void QsLogging::SizeRotationStrategy::setMaximumSizeInBytes(qint64 size)
|
||||
{
|
||||
Q_ASSERT(size >= 0);
|
||||
mMaxSizeInBytes = size;
|
||||
}
|
||||
|
||||
void QsLogging::SizeRotationStrategy::setBackupCount(int backups)
|
||||
{
|
||||
Q_ASSERT(backups >= 0);
|
||||
mBackupsCount = qMin(backups, SizeRotationStrategy::MaxBackupCount);
|
||||
}
|
||||
|
||||
qint64 QsLogging::SizeRotationStrategy::currentSizeInBytes()
|
||||
{
|
||||
return mCurrentSizeInBytes;
|
||||
}
|
||||
|
||||
QsLogging::FileDestination::FileDestination(const QString& filePath, RotationStrategyPtr rotationStrategy)
|
||||
: mRotationStrategy(rotationStrategy)
|
||||
{
|
||||
mFile.setFileName(filePath);
|
||||
if (!mFile.open(QFile::WriteOnly | QFile::Text | mRotationStrategy->recommendedOpenModeFlag()))
|
||||
std::cerr << "QsLog: could not open log file " << qPrintable(filePath);
|
||||
mOutputStream.setDevice(&mFile);
|
||||
mOutputStream.setCodec("UTF-8");
|
||||
|
||||
mRotationStrategy->setInitialInfo(mFile);
|
||||
}
|
||||
|
||||
void QsLogging::FileDestination::write(const QString& message, Level)
|
||||
{
|
||||
mRotationStrategy->includeMessageInCalculation(message);
|
||||
if (mRotationStrategy->shouldRotate())
|
||||
rotate();
|
||||
|
||||
mOutputStream << message << "\n";
|
||||
mOutputStream.flush();
|
||||
}
|
||||
|
||||
bool QsLogging::FileDestination::isValid()
|
||||
{
|
||||
return mFile.isOpen();
|
||||
}
|
||||
|
||||
void QsLogging::FileDestination::rotate()
|
||||
{
|
||||
mOutputStream.setDevice(NULL);
|
||||
mFile.close();
|
||||
mRotationStrategy->rotate();
|
||||
if (!mFile.open(QFile::WriteOnly | QFile::Text | mRotationStrategy->recommendedOpenModeFlag()))
|
||||
std::cerr << "QsLog: could not reopen log file " << qPrintable(mFile.fileName());
|
||||
mRotationStrategy->setInitialInfo(mFile);
|
||||
mOutputStream.setDevice(&mFile);
|
||||
mOutputStream.setCodec("UTF-8");
|
||||
}
|
106
external/qslog/QsLogDestFile.h
vendored
106
external/qslog/QsLogDestFile.h
vendored
@ -1,106 +0,0 @@
|
||||
// Copyright (c) 2013, Razvan Petru
|
||||
// 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 QSLOGDESTFILE_H
|
||||
#define QSLOGDESTFILE_H
|
||||
|
||||
#include "QsLogDest.h"
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QtGlobal>
|
||||
#include <QSharedPointer>
|
||||
|
||||
namespace QsLogging
|
||||
{
|
||||
class RotationStrategy
|
||||
{
|
||||
public:
|
||||
virtual ~RotationStrategy();
|
||||
|
||||
virtual void setInitialInfo(const QFile &file) = 0;
|
||||
virtual void includeMessageInCalculation(const QString &message) = 0;
|
||||
virtual bool shouldRotate() = 0;
|
||||
virtual void rotate() = 0;
|
||||
virtual QIODevice::OpenMode recommendedOpenModeFlag() = 0;
|
||||
virtual qint64 currentSizeInBytes() {return 0;}
|
||||
};
|
||||
|
||||
// Never rotates file, overwrites existing file.
|
||||
class NullRotationStrategy : public RotationStrategy
|
||||
{
|
||||
public:
|
||||
virtual void setInitialInfo(const QFile &) {}
|
||||
virtual void includeMessageInCalculation(const QString &) {}
|
||||
virtual bool shouldRotate() { return false; }
|
||||
virtual void rotate() {}
|
||||
virtual QIODevice::OpenMode recommendedOpenModeFlag() { return QIODevice::Truncate; }
|
||||
};
|
||||
|
||||
// Rotates after a size is reached, keeps a number of <= 10 backups, appends to existing file.
|
||||
class SizeRotationStrategy : public RotationStrategy
|
||||
{
|
||||
public:
|
||||
SizeRotationStrategy();
|
||||
static const int MaxBackupCount;
|
||||
|
||||
virtual void setInitialInfo(const QFile &file);
|
||||
virtual void includeMessageInCalculation(const QString &message);
|
||||
virtual bool shouldRotate();
|
||||
virtual void rotate();
|
||||
virtual QIODevice::OpenMode recommendedOpenModeFlag();
|
||||
virtual qint64 currentSizeInBytes();
|
||||
|
||||
void setMaximumSizeInBytes(qint64 size);
|
||||
void setBackupCount(int backups);
|
||||
|
||||
private:
|
||||
QString mFileName;
|
||||
qint64 mCurrentSizeInBytes;
|
||||
qint64 mMaxSizeInBytes;
|
||||
int mBackupsCount;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<RotationStrategy> RotationStrategyPtr;
|
||||
|
||||
// file message sink
|
||||
class FileDestination : public Destination
|
||||
{
|
||||
public:
|
||||
FileDestination(const QString& filePath, RotationStrategyPtr rotationStrategy);
|
||||
virtual void write(const QString& message, Level level);
|
||||
virtual bool isValid();
|
||||
virtual void rotate();
|
||||
|
||||
QSharedPointer<RotationStrategy> rotationStrategy() { return mRotationStrategy; }
|
||||
|
||||
private:
|
||||
QFile mFile;
|
||||
QTextStream mOutputStream;
|
||||
QSharedPointer<RotationStrategy> mRotationStrategy;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // QSLOGDESTFILE_H
|
57
external/qslog/QsLogDestFunctor.cpp
vendored
57
external/qslog/QsLogDestFunctor.cpp
vendored
@ -1,57 +0,0 @@
|
||||
// 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;
|
||||
}
|
60
external/qslog/QsLogDestFunctor.h
vendored
60
external/qslog/QsLogDestFunctor.h
vendored
@ -1,60 +0,0 @@
|
||||
// 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();
|
||||
virtual void rotate() { }
|
||||
|
||||
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
|
22
external/qslog/QsLogDisableForThisFile.h
vendored
22
external/qslog/QsLogDisableForThisFile.h
vendored
@ -1,22 +0,0 @@
|
||||
#ifndef QSLOGDISABLEFORTHISFILE_H
|
||||
#define QSLOGDISABLEFORTHISFILE_H
|
||||
|
||||
#include <QtDebug>
|
||||
// When included AFTER QsLog.h, this file will disable logging in that C++ file. When included
|
||||
// before, it will lead to compiler warnings or errors about macro redefinitions.
|
||||
|
||||
#undef QLOG_TRACE
|
||||
#undef QLOG_DEBUG
|
||||
#undef QLOG_INFO
|
||||
#undef QLOG_WARN
|
||||
#undef QLOG_ERROR
|
||||
#undef QLOG_FATAL
|
||||
|
||||
#define QLOG_TRACE() if (1) {} else qDebug()
|
||||
#define QLOG_DEBUG() if (1) {} else qDebug()
|
||||
#define QLOG_INFO() if (1) {} else qDebug()
|
||||
#define QLOG_WARN() if (1) {} else qDebug()
|
||||
#define QLOG_ERROR() if (1) {} else qDebug()
|
||||
#define QLOG_FATAL() if (1) {} else qDebug()
|
||||
|
||||
#endif // QSLOGDISABLEFORTHISFILE_H
|
45
external/qslog/QsLogLevel.h
vendored
45
external/qslog/QsLogLevel.h
vendored
@ -1,45 +0,0 @@
|
||||
// Copyright (c) 2013, Razvan Petru
|
||||
// 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 QSLOGLEVEL_H
|
||||
#define QSLOGLEVEL_H
|
||||
|
||||
namespace QsLogging
|
||||
{
|
||||
|
||||
enum Level
|
||||
{
|
||||
TraceLevel = 0,
|
||||
DebugLevel,
|
||||
InfoLevel,
|
||||
WarnLevel,
|
||||
ErrorLevel,
|
||||
FatalLevel,
|
||||
OffLevel
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // QSLOGLEVEL_H
|
65
external/qslog/QsLogReadme.txt
vendored
65
external/qslog/QsLogReadme.txt
vendored
@ -1,65 +0,0 @@
|
||||
QsLog - the simple Qt logger
|
||||
-------------------------------------------------------------------------------
|
||||
QsLog is an easy to use logger that is based on Qt's QDebug class.
|
||||
|
||||
Features
|
||||
-------------------------------------------------------------------------------
|
||||
* Six logging levels (from trace to fatal)
|
||||
* Logging level threshold configurable at runtime.
|
||||
* Minimum overhead when logging is turned off.
|
||||
* Multiple destinations, comes with file and debug destinations.
|
||||
* Thread-safe
|
||||
* Logging of common Qt types out of the box.
|
||||
* Immediate logging or queueing messages in a separate thread.
|
||||
* Small dependency: just drop it in your project directly.
|
||||
|
||||
Usage
|
||||
-------------------------------------------------------------------------------
|
||||
By directly including QsLog in your project:
|
||||
1. Include QsLog.pri in your pro file
|
||||
2. Include QsLog.h in your C++ files. Include QsLogDest.h only where you create/add destinations.
|
||||
3. Get the instance of the logger by calling QsLogging::Logger::instance();
|
||||
4. Optionally set the logging level. Info is default.
|
||||
5. Create as many destinations as you want by using the QsLogging::DestinationFactory.
|
||||
6. Add the destinations to the logger instance by calling addDestination.
|
||||
7. Start logging!
|
||||
Note: when you want to use QsLog both from an executable and a shared library you have to
|
||||
link dynamically with QsLog due to a limitation with static variables.
|
||||
|
||||
By linking to QsLog dynamically:
|
||||
1. Build QsLog using the QsLogSharedLibrary.pro.
|
||||
2. Add the QsLog shared library to your LIBS project dependencies.
|
||||
3. Follow the steps in "directly including QsLog in your project" starting with step 2.
|
||||
|
||||
Configuration
|
||||
-------------------------------------------------------------------------------
|
||||
QsLog has several configurable parameters:
|
||||
* defining QS_LOG_LINE_NUMBERS in the .pri file enables writing the file and line number
|
||||
automatically for each logging call
|
||||
* defining QS_LOG_SEPARATE_THREAD will route all log messages to a separate thread.
|
||||
|
||||
Sometimes it's necessary to turn off logging. This can be done in several ways:
|
||||
* globally, at compile time, by enabling the QS_LOG_DISABLE macro in the .pri file.
|
||||
* globally, at run time, by setting the log level to "OffLevel".
|
||||
* per file, at compile time, by including QsLogDisableForThisFile.h in the target file.
|
||||
|
||||
Thread safety
|
||||
-------------------------------------------------------------------------------
|
||||
The Qt docs say: A thread-safe function can be called simultaneously from multiple threads,
|
||||
even when the invocations use shared data, because all references to the shared data are serialized.
|
||||
A reentrant function can also be called simultaneously from multiple threads, but only if each
|
||||
invocation uses its own data.
|
||||
|
||||
Since sending the log message to the destinations is protected by a mutex, the logging macros are
|
||||
thread-safe provided that the log has been initialized - i.e: instance() has been called.
|
||||
The instance function and the setup functions (e.g: setLoggingLevel, addDestination) are NOT
|
||||
thread-safe and are NOT reentrant.
|
||||
|
||||
IMPORTANT: when using a separate thread for logging, your program might crash at exit time on some
|
||||
operating systems if you won't call Logger::destroyInstance() before your program exits.
|
||||
This function can be called either before returning from main in a console app or
|
||||
inside QCoreApplication::aboutToQuit in a Qt GUI app.
|
||||
The reason is that the logging thread is still running as some objects are destroyed by
|
||||
the OS. Calling destroyInstance will wait for the thread to finish.
|
||||
Nothing will happen if you forget to call the function when not using a separate thread
|
||||
for logging.
|
@ -1,32 +1,3 @@
|
||||
qslog:
|
||||
------
|
||||
|
||||
Copyright (c) 2014, Razvan Petru
|
||||
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.
|
||||
|
||||
|
||||
Broadcom RPI decoder:
|
||||
---------------------
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/external/qslog
|
||||
${CMAKE_SOURCE_DIR}/external/SPMediaKeyTap
|
||||
${CMAKE_SOURCE_DIR}/external/HIDRemote
|
||||
${CMAKE_SOURCE_DIR}/external/plistparser
|
||||
@ -169,7 +168,6 @@ endif()
|
||||
|
||||
target_link_libraries(${MAIN_TARGET}
|
||||
shared
|
||||
qslog
|
||||
${MPV_LIBRARY}
|
||||
${OPENGL_LIBS}
|
||||
${QT5_LIBRARIES}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <QObject>
|
||||
#include <QtQml>
|
||||
#include <qqmlwebchannel.h>
|
||||
#include <QDebug>
|
||||
|
||||
#include "ComponentManager.h"
|
||||
|
||||
@ -16,8 +17,6 @@
|
||||
#include "system/openelec/OESystemComponent.h"
|
||||
#endif
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
ComponentManager::ComponentManager() : QObject(nullptr)
|
||||
{
|
||||
@ -28,13 +27,13 @@ void ComponentManager::registerComponent(ComponentBase* comp)
|
||||
{
|
||||
if (m_components.contains(comp->componentName()))
|
||||
{
|
||||
QLOG_ERROR() << "Component" << comp->componentName() << "already registered!";
|
||||
qCritical() << "Component" << comp->componentName() << "already registered!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (comp->componentInitialize())
|
||||
{
|
||||
QLOG_INFO() << "Component:" << comp->componentName() << "inited";
|
||||
qInfo() << "Component:" << comp->componentName() << "inited";
|
||||
m_components[comp->componentName()] = comp;
|
||||
|
||||
// define component as property for qml
|
||||
@ -42,7 +41,7 @@ void ComponentManager::registerComponent(ComponentBase* comp)
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "Failed to init component:" << comp->componentName();
|
||||
qCritical() << "Failed to init component:" << comp->componentName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +74,7 @@ void ComponentManager::setWebChannel(QWebChannel* webChannel)
|
||||
{
|
||||
if (comp->componentExport())
|
||||
{
|
||||
QLOG_DEBUG() << "Adding component:" << comp->componentName() << "to webchannel";
|
||||
qDebug() << "Adding component:" << comp->componentName() << "to webchannel";
|
||||
webChannel->registerObject(comp->componentName(), comp);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "sys/socket.h"
|
||||
#include "unistd.h"
|
||||
#include "signal.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
#include "SignalManager.h"
|
||||
#include "settings/SettingsComponent.h"
|
||||
|
||||
@ -13,14 +14,14 @@ SignalManager::SignalManager(QGuiApplication* app) : QObject(nullptr), m_app(app
|
||||
{
|
||||
if (setupHandlers())
|
||||
{
|
||||
QLOG_ERROR() << "Failed to install SignalDaemon handlers.";
|
||||
qCritical() << "Failed to install SignalDaemon handlers.";
|
||||
}
|
||||
|
||||
QLOG_DEBUG() << "Signal handlers installed successfully.";
|
||||
qDebug() << "Signal handlers installed successfully.";
|
||||
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, SignalManager::g_sigtermFd))
|
||||
{
|
||||
QLOG_ERROR() << "Couldn't create TERM socketpair";
|
||||
qCritical() << "Couldn't create TERM socketpair";
|
||||
}
|
||||
|
||||
m_snTerm = new QSocketNotifier(SignalManager::g_sigtermFd[1], QSocketNotifier::Read, this);
|
||||
@ -66,12 +67,12 @@ void SignalManager::handleSignal()
|
||||
// do Qt stuff
|
||||
if (signalNumber == SIGUSR1)
|
||||
{
|
||||
QLOG_DEBUG() << "Received SIGUSR1, reloading config file";
|
||||
qDebug() << "Received SIGUSR1, reloading config file";
|
||||
SettingsComponent::Get().load();
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_DEBUG() << "Received signal, closing application";
|
||||
qDebug() << "Received signal, closing application";
|
||||
closeApplication();
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
#include "QsLog.h"
|
||||
#include "DisplayComponent.h"
|
||||
#include "DisplayManager.h"
|
||||
#include "settings/SettingsComponent.h"
|
||||
#include <QGuiApplication>
|
||||
#include <QWindow>
|
||||
#include <QDebug>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
@ -78,7 +78,7 @@ bool DisplayComponent::componentInitialize()
|
||||
|
||||
#ifdef TARGET_RPI
|
||||
// The firmware doesn't always make the best decision. Hope we do better.
|
||||
QLOG_INFO() << "Trying to switch to best display mode.";
|
||||
qInfo() << "Trying to switch to best display mode.";
|
||||
switchToBestOverallVideoMode(0);
|
||||
#endif
|
||||
|
||||
@ -91,7 +91,7 @@ bool DisplayComponent::componentInitialize()
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void DisplayComponent::monitorChange()
|
||||
{
|
||||
QLOG_INFO() << "Monitor change detected.";
|
||||
qInfo() << "Monitor change detected.";
|
||||
|
||||
if (!m_initTimer.isSingleShot())
|
||||
{
|
||||
@ -111,7 +111,7 @@ bool DisplayComponent::switchToBestVideoMode(float frameRate)
|
||||
int currentDisplay = getApplicationDisplay();
|
||||
if (currentDisplay < 0)
|
||||
{
|
||||
QLOG_INFO() << "Not switching rate - current display not found.";
|
||||
qInfo() << "Not switching rate - current display not found.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ bool DisplayComponent::switchToBestVideoMode(float frameRate)
|
||||
m_lastDisplay = currentDisplay;
|
||||
}
|
||||
|
||||
QLOG_DEBUG() << "Current display:" << currentDisplay << "mode:" << currentMode;
|
||||
qDebug() << "Current display:" << currentDisplay << "mode:" << currentMode;
|
||||
|
||||
DMMatchMediaInfo matchInfo(frameRate, false);
|
||||
int bestmode = m_displayManager->findBestMatch(currentDisplay, matchInfo);
|
||||
@ -130,23 +130,23 @@ bool DisplayComponent::switchToBestVideoMode(float frameRate)
|
||||
{
|
||||
if (bestmode != currentMode)
|
||||
{
|
||||
QLOG_DEBUG()
|
||||
qDebug()
|
||||
<< "Best video matching mode is "
|
||||
<< m_displayManager->m_displays[currentDisplay]->m_videoModes[bestmode]->getPrettyName()
|
||||
<< "on display" << currentDisplay;
|
||||
|
||||
if (!m_displayManager->setDisplayMode(currentDisplay, bestmode))
|
||||
{
|
||||
QLOG_INFO() << "Mode switching failed.";
|
||||
qInfo() << "Mode switching failed.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
QLOG_INFO() << "No better video mode than the currently active one found.";
|
||||
qInfo() << "No better video mode than the currently active one found.";
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_DEBUG() << "No video mode found as better match.";
|
||||
qDebug() << "No video mode found as better match.";
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -162,7 +162,7 @@ bool DisplayComponent::switchToBestOverallVideoMode(int display)
|
||||
|
||||
if (!SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "hdmi_poweron").toBool())
|
||||
{
|
||||
QLOG_INFO() << "Switching to best mode disabled.";
|
||||
qInfo() << "Switching to best mode disabled.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -170,21 +170,21 @@ bool DisplayComponent::switchToBestOverallVideoMode(int display)
|
||||
if (bestmode < 0)
|
||||
return false;
|
||||
|
||||
QLOG_INFO() << "We think mode" << bestmode << "is the best mode.";
|
||||
qInfo() << "We think mode" << bestmode << "is the best mode.";
|
||||
|
||||
if (bestmode == m_displayManager->getCurrentDisplayMode(display))
|
||||
{
|
||||
QLOG_INFO() << "This mode is the currently active one. Not switching.";
|
||||
qInfo() << "This mode is the currently active one. Not switching.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_displayManager->setDisplayMode(display, bestmode))
|
||||
{
|
||||
QLOG_INFO() << "Switching mode failed.";
|
||||
qInfo() << "Switching mode failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
QLOG_INFO() << "Switching mode successful.";
|
||||
qInfo() << "Switching mode successful.";
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ bool DisplayComponent::restorePreviousVideoMode()
|
||||
|
||||
if (m_displayManager->getCurrentDisplayMode(m_lastDisplay) != m_lastVideoMode)
|
||||
{
|
||||
QLOG_DEBUG()
|
||||
qDebug()
|
||||
<< "Restoring VideoMode to"
|
||||
<< m_displayManager->m_displays[m_lastDisplay]->m_videoModes[m_lastVideoMode]->getPrettyName()
|
||||
<< "on display" << m_lastDisplay;
|
||||
@ -243,7 +243,7 @@ int DisplayComponent::getApplicationDisplay(bool silent)
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
QLOG_TRACE() << "Looking for a display at:" << activeWindow->geometry()
|
||||
qInfo() << "Looking for a display at:" << activeWindow->geometry()
|
||||
<< "(center:" << activeWindow->geometry().center() << ")";
|
||||
}
|
||||
display = m_displayManager->getDisplayFromPoint(activeWindow->geometry().center());
|
||||
@ -251,7 +251,7 @@ int DisplayComponent::getApplicationDisplay(bool silent)
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
QLOG_TRACE() << "Display index:" << display;
|
||||
qInfo() << "Display index:" << display;
|
||||
}
|
||||
return display;
|
||||
}
|
||||
@ -327,26 +327,26 @@ void DisplayComponent::switchCommand(QString command)
|
||||
{
|
||||
if (!m_displayManager)
|
||||
{
|
||||
QLOG_ERROR() << "Display manager not set";
|
||||
qCritical() << "Display manager not set";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!initializeDisplayManager())
|
||||
{
|
||||
QLOG_ERROR() << "Could not reinitialize display manager";
|
||||
qCritical() << "Could not reinitialize display manager";
|
||||
return;
|
||||
}
|
||||
|
||||
int currentDisplay = getApplicationDisplay();
|
||||
if (currentDisplay < 0)
|
||||
{
|
||||
QLOG_ERROR() << "Current display not found";
|
||||
qCritical() << "Current display not found";
|
||||
return;
|
||||
}
|
||||
int id = m_displayManager->getCurrentDisplayMode(currentDisplay);
|
||||
if (id < 0)
|
||||
{
|
||||
QLOG_ERROR() << "Current mode not found";
|
||||
qCritical() << "Current mode not found";
|
||||
return;
|
||||
}
|
||||
DMVideoMode currentMode = *m_displayManager->m_displays[currentDisplay]->m_videoModes[id];
|
||||
@ -397,11 +397,11 @@ void DisplayComponent::switchCommand(QString command)
|
||||
}
|
||||
}
|
||||
|
||||
QLOG_INFO() << "Current mode:" << currentMode.getPrettyName();
|
||||
qInfo() << "Current mode:" << currentMode.getPrettyName();
|
||||
|
||||
if (bestMode < 0)
|
||||
{
|
||||
QLOG_INFO() << "Mode requested by command:" << mode.getPrettyName();
|
||||
qInfo() << "Mode requested by command:" << mode.getPrettyName();
|
||||
|
||||
for(auto cur : m_displayManager->m_displays[currentDisplay]->m_videoModes)
|
||||
{
|
||||
@ -426,19 +426,19 @@ void DisplayComponent::switchCommand(QString command)
|
||||
|
||||
if (bestMode >= 0)
|
||||
{
|
||||
QLOG_INFO() << "Found mode to switch to:" << m_displayManager->m_displays[currentDisplay]->m_videoModes[bestMode]->getPrettyName();
|
||||
qInfo() << "Found mode to switch to:" << m_displayManager->m_displays[currentDisplay]->m_videoModes[bestMode]->getPrettyName();
|
||||
if (m_displayManager->setDisplayMode(currentDisplay, bestMode))
|
||||
{
|
||||
m_lastDisplay = m_lastVideoMode = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_INFO() << "Switching failed.";
|
||||
qInfo() << "Switching failed.";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QLOG_INFO() << "Requested mode not found.";
|
||||
qInfo() << "Requested mode not found.";
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -6,7 +6,7 @@
|
||||
//
|
||||
//
|
||||
|
||||
#include "QsLog.h"
|
||||
#include <QDebug>
|
||||
#include "DisplayManager.h"
|
||||
#include "math.h"
|
||||
#include "settings/SettingsComponent.h"
|
||||
@ -17,17 +17,17 @@ DisplayManager::DisplayManager(QObject* parent) : QObject(parent) {}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool DisplayManager::initialize()
|
||||
{
|
||||
QLOG_INFO() << QString("DisplayManager found %1 Display(s).").arg(m_displays.size());
|
||||
qInfo() << QString("DisplayManager found %1 Display(s).").arg(m_displays.size());
|
||||
|
||||
// list video modes
|
||||
for(int displayid : m_displays.keys())
|
||||
{
|
||||
DMDisplayPtr display = m_displays[displayid];
|
||||
QLOG_INFO() << QString("Available modes for Display #%1 (%2)").arg(displayid).arg(display->m_name);
|
||||
qInfo() << QString("Available modes for Display #%1 (%2)").arg(displayid).arg(display->m_name);
|
||||
for (int modeid = 0; modeid < display->m_videoModes.size(); modeid++)
|
||||
{
|
||||
DMVideoModePtr mode = display->m_videoModes[modeid];
|
||||
QLOG_INFO() << QString("Mode %1: %2").arg(modeid, 2).arg(mode->getPrettyName());
|
||||
qInfo() << QString("Mode %1: %2").arg(modeid, 2).arg(mode->getPrettyName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,14 +37,14 @@ bool DisplayManager::initialize()
|
||||
{
|
||||
int currentMode = getCurrentDisplayMode(mainDisplay);
|
||||
if (currentMode >= 0)
|
||||
QLOG_INFO() << QString("DisplayManager : Current Display Mode on Display #%1 is %2")
|
||||
qInfo() << QString("DisplayManager : Current Display Mode on Display #%1 is %2")
|
||||
.arg(mainDisplay)
|
||||
.arg(m_displays[mainDisplay]->m_videoModes[currentMode]->getPrettyName());
|
||||
else
|
||||
QLOG_ERROR() << "DisplayManager : unable to retrieve current video mode";
|
||||
qCritical() << "DisplayManager : unable to retrieve current video mode";
|
||||
}
|
||||
else
|
||||
QLOG_ERROR() << "DisplayManager : unable to retrieve main display";
|
||||
qCritical() << "DisplayManager : unable to retrieve main display";
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -122,7 +122,7 @@ int DisplayManager::findBestMatch(int display, DMMatchMediaInfo& matchInfo)
|
||||
{
|
||||
if (avoid_25_30)
|
||||
{
|
||||
QLOG_INFO() << "DisplayManager RefreshMatch : skipping rate " << candidate->m_refreshRate << "as requested";
|
||||
qInfo() << "DisplayManager RefreshMatch : skipping rate " << candidate->m_refreshRate << "as requested";
|
||||
modeit++;
|
||||
continue;
|
||||
}
|
||||
@ -176,7 +176,7 @@ int DisplayManager::findBestMatch(int display, DMMatchMediaInfo& matchInfo)
|
||||
DMVideoModeWeightMap::const_iterator weightit = weights.constBegin();
|
||||
while (weightit != weights.constEnd())
|
||||
{
|
||||
QLOG_DEBUG() << "Mode " << weightit.value()->m_mode->m_id << "("
|
||||
qDebug() << "Mode " << weightit.value()->m_mode->m_id << "("
|
||||
<< weightit.value()->m_mode->getPrettyName() << ") has weight "
|
||||
<< weightit.value()->m_weight;
|
||||
if (weightit.value()->m_weight > maxWeight)
|
||||
@ -190,12 +190,12 @@ int DisplayManager::findBestMatch(int display, DMMatchMediaInfo& matchInfo)
|
||||
|
||||
if ((chosen) && (chosen->m_weight > MATCH_WEIGHT_RES))
|
||||
{
|
||||
QLOG_INFO() << "DisplayManager RefreshMatch : found a suitable mode : "
|
||||
qInfo() << "DisplayManager RefreshMatch : found a suitable mode : "
|
||||
<< chosen->m_mode->getPrettyName();
|
||||
return chosen->m_mode->m_id;
|
||||
}
|
||||
|
||||
QLOG_INFO() << "DisplayManager RefreshMatch : found no suitable videomode";
|
||||
qInfo() << "DisplayManager RefreshMatch : found no suitable videomode";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "QsLog.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include "DisplayManagerDummy.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -41,7 +42,7 @@ bool DisplayManagerDummy::setDisplayMode(int display, int mode)
|
||||
DMDisplayPtr displayptr = m_displays[display];
|
||||
DMVideoModePtr videomode = displayptr->m_videoModes[mode];
|
||||
|
||||
QLOG_INFO() << "Switching to" << videomode->m_width << "x" << videomode->m_height << "@" << videomode->m_refreshRate;
|
||||
qInfo() << "Switching to" << videomode->m_width << "x" << videomode->m_height << "@" << videomode->m_refreshRate;
|
||||
|
||||
m_currentMode = videomode->m_id;
|
||||
|
||||
|
@ -7,11 +7,10 @@
|
||||
//
|
||||
|
||||
#include <CoreGraphics/CoreGraphics.h>
|
||||
#include <QDebug>
|
||||
#include "utils/osx/OSXUtils.h"
|
||||
#include "DisplayManagerOSX.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool DisplayManagerOSX::initialize()
|
||||
{
|
||||
@ -30,7 +29,7 @@ bool DisplayManagerOSX::initialize()
|
||||
if (err)
|
||||
{
|
||||
m_osxnumDisplays = 0;
|
||||
QLOG_ERROR() << "CGGetActiveDisplayList returned failure:" << err;
|
||||
qCritical() << "CGGetActiveDisplayList returned failure:" << err;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -101,7 +100,7 @@ bool DisplayManagerOSX::setDisplayMode(int display, int mode)
|
||||
CGError err = CGDisplaySetDisplayMode(m_osxDisplays[display], displayMode, nullptr);
|
||||
if (err)
|
||||
{
|
||||
QLOG_ERROR() << "CGDisplaySetDisplayMode() returned failure:" << err;
|
||||
qCritical() << "CGDisplaySetDisplayMode() returned failure:" << err;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQuickWindow>
|
||||
#include <QDebug>
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <qpa/qplatformintegration.h>
|
||||
|
||||
#include "QsLog.h"
|
||||
#include "DisplayManagerRPI.h"
|
||||
#include "display/DisplayComponent.h"
|
||||
|
||||
@ -35,7 +35,7 @@ DisplayManagerRPI::~DisplayManagerRPI()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void DisplayManagerRPI::handleTvChange(uint32_t reason)
|
||||
{
|
||||
QLOG_INFO() << "tv_service notification:" << reason;
|
||||
qInfo() << "tv_service notification:" << reason;
|
||||
|
||||
if (reason & (VC_HDMI_DVI | VC_HDMI_HDMI))
|
||||
{
|
||||
@ -45,13 +45,13 @@ void DisplayManagerRPI::handleTvChange(uint32_t reason)
|
||||
else if (reason & VC_HDMI_ATTACHED)
|
||||
{
|
||||
// Plugged in, but is in standby mode. May happen when reconnecting a monitor via HDMI.
|
||||
QLOG_INFO() << "Powering on screen.";
|
||||
qInfo() << "Powering on screen.";
|
||||
initialize();
|
||||
DisplayComponent::Get().switchToBestOverallVideoMode(0);
|
||||
}
|
||||
else if (reason & VC_HDMI_UNPLUGGED)
|
||||
{
|
||||
QLOG_INFO() << "Screen was unplugged.";
|
||||
qInfo() << "Screen was unplugged.";
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ bool DisplayManagerRPI::setDisplayMode(int display, int mode)
|
||||
bool ret = vc_tv_hdmi_power_on_explicit_new(HDMI_MODE_HDMI, (HDMI_RES_GROUP_T)tvmode->group, tvmode->code) == 0;
|
||||
if (!ret)
|
||||
{
|
||||
QLOG_ERROR() << "Failed to switch display mode" << ret;
|
||||
qCritical() << "Failed to switch display mode" << ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -173,7 +173,7 @@ void DisplayManagerRPI::resetRendering()
|
||||
QQuickWindow *window = (QQuickWindow*)guiApp->focusWindow();
|
||||
if (window)
|
||||
{
|
||||
QLOG_INFO() << "Recreating Qt UI renderer";
|
||||
qInfo() << "Recreating Qt UI renderer";
|
||||
|
||||
// destroy the window to reset OpenGL context
|
||||
window->setPersistentOpenGLContext(false);
|
||||
@ -193,7 +193,7 @@ void DisplayManagerRPI::resetRendering()
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "Failed to retrieve platform integration";
|
||||
qCritical() << "Failed to retrieve platform integration";
|
||||
}
|
||||
|
||||
// now recreate the window OpenGL context
|
||||
|
@ -7,9 +7,9 @@
|
||||
//
|
||||
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
#include <math.h>
|
||||
|
||||
#include "QsLog.h"
|
||||
#include "DisplayManagerWin.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -81,7 +81,7 @@ bool DisplayManagerWin::initialize()
|
||||
|
||||
if (m_displays.isEmpty())
|
||||
{
|
||||
QLOG_DEBUG() << "No display found.";
|
||||
qDebug() << "No display found.";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@ -98,7 +98,7 @@ bool DisplayManagerWin::setDisplayMode(int display, int mode)
|
||||
|
||||
if (getModeInfo(display, mode, modeInfo))
|
||||
{
|
||||
QLOG_DEBUG() << "Switching to mode" << mode << "on display" << display << ":" << m_displays[display]->m_videoModes[mode]->getPrettyName();
|
||||
qDebug() << "Switching to mode" << mode << "on display" << display << ":" << m_displays[display]->m_videoModes[mode]->getPrettyName();
|
||||
|
||||
modeInfo.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS;
|
||||
|
||||
@ -107,7 +107,7 @@ bool DisplayManagerWin::setDisplayMode(int display, int mode)
|
||||
|
||||
if (rc != DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
QLOG_ERROR() << "Failed to changed DisplayMode, error" << rc;
|
||||
qCritical() << "Failed to changed DisplayMode, error" << rc;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@ -134,7 +134,7 @@ int DisplayManagerWin::getCurrentDisplayMode(int display)
|
||||
if (!EnumDisplaySettingsW((LPCWSTR)m_displayAdapters[display].utf16(), ENUM_CURRENT_SETTINGS,
|
||||
&modeInfo))
|
||||
{
|
||||
QLOG_ERROR() << "Failed to retrieve current mode";
|
||||
qCritical() << "Failed to retrieve current mode";
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -181,18 +181,18 @@ int DisplayManagerWin::getDisplayFromPoint(int x, int y)
|
||||
DEVMODEW modeInfo = {};
|
||||
modeInfo.dmSize = sizeof(modeInfo);
|
||||
|
||||
QLOG_TRACE() << "Looking at display" << displayId << dispName;
|
||||
qInfo() << "Looking at display" << displayId << dispName;
|
||||
|
||||
if (!EnumDisplaySettingsW((LPCWSTR)dispName.utf16(), ENUM_CURRENT_SETTINGS,
|
||||
&modeInfo))
|
||||
{
|
||||
QLOG_ERROR() << "Failed to retrieve current mode.";
|
||||
qCritical() << "Failed to retrieve current mode.";
|
||||
}
|
||||
else
|
||||
{
|
||||
QRect displayRect(modeInfo.dmPosition.x, modeInfo.dmPosition.y, modeInfo.dmPelsWidth,
|
||||
modeInfo.dmPelsHeight);
|
||||
QLOG_TRACE() << "Position on virtual desktop:" << displayRect;
|
||||
qInfo() << "Position on virtual desktop:" << displayRect;
|
||||
|
||||
if (displayRect.contains(x, y))
|
||||
return displayId;
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include "QsLog.h"
|
||||
#include <QDebug>
|
||||
#include "InputCEC.h"
|
||||
#include "settings/SettingsComponent.h"
|
||||
#include "power/PowerComponent.h"
|
||||
@ -105,11 +105,11 @@ bool InputCECWorker::init()
|
||||
m_adapter = (ICECAdapter*)CECInitialise(&m_configuration);
|
||||
if (!m_adapter)
|
||||
{
|
||||
QLOG_ERROR() << "Unable to initialize libCEC.";
|
||||
qCritical() << "Unable to initialize libCEC.";
|
||||
return false;
|
||||
}
|
||||
|
||||
QLOG_INFO() << "libCEC was successfully initialized, found version"
|
||||
qInfo() << "libCEC was successfully initialized, found version"
|
||||
<< m_configuration.serverVersion;
|
||||
|
||||
// init video on targets that need this
|
||||
@ -138,7 +138,7 @@ void InputCECWorker::closeCec()
|
||||
|
||||
if (m_adapter)
|
||||
{
|
||||
QLOG_DEBUG() << "Closing libCEC.";
|
||||
qDebug() << "Closing libCEC.";
|
||||
closeAdapter();
|
||||
CECDestroy(m_adapter);
|
||||
}
|
||||
@ -155,18 +155,18 @@ bool InputCECWorker::openAdapter()
|
||||
if (devicesCount > 0)
|
||||
{
|
||||
// list devices
|
||||
QLOG_INFO() << "libCEC found" << devicesCount << "CEC adapters.";
|
||||
qInfo() << "libCEC found" << devicesCount << "CEC adapters.";
|
||||
|
||||
// open first adapter
|
||||
m_adapterPort = devices[0].strComName;
|
||||
if (m_adapter->Open(m_adapterPort.toStdString().c_str()))
|
||||
{
|
||||
QLOG_INFO() << "Device " << devices[0].strComName << "was successfully openned";
|
||||
qInfo() << "Device " << devices[0].strComName << "was successfully openned";
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "Opening device" << devices[0].strComName << "failed";
|
||||
qCritical() << "Opening device" << devices[0].strComName << "failed";
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
@ -222,21 +222,21 @@ void InputCECWorker::CecLogMessage(void* cbParam, const cec_log_message *message
|
||||
switch (message->level)
|
||||
{
|
||||
case CEC_LOG_ERROR:
|
||||
QLOG_ERROR() << "libCEC ERROR:" << message->message;
|
||||
qCritical() << "libCEC ERROR:" << message->message;
|
||||
break;
|
||||
|
||||
case CEC_LOG_WARNING:
|
||||
QLOG_WARN() << "libCEC WARNING:" << message->message;
|
||||
qWarning() << "libCEC WARNING:" << message->message;
|
||||
break;
|
||||
|
||||
case CEC_LOG_NOTICE:
|
||||
QLOG_INFO() << "libCEC NOTICE:" << message->message;
|
||||
qInfo() << "libCEC NOTICE:" << message->message;
|
||||
break;
|
||||
|
||||
case CEC_LOG_DEBUG:
|
||||
if (cec->m_verboseLogging)
|
||||
{
|
||||
QLOG_DEBUG() << "libCEC DEBUG:" << message->message;
|
||||
qDebug() << "libCEC DEBUG:" << message->message;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -274,7 +274,7 @@ void InputCECWorker::CecCommand(void *cbParam, const cec_command *command)
|
||||
|
||||
if (cec->m_verboseLogging)
|
||||
{
|
||||
QLOG_DEBUG() << "CecCommand received " << QString::number(command->opcode, 16).toUpper() << "," << cec->getCommandParamsList(command);
|
||||
qDebug() << "CecCommand received " << QString::number(command->opcode, 16).toUpper() << "," << cec->getCommandParamsList(command);
|
||||
}
|
||||
|
||||
switch(command->opcode)
|
||||
@ -324,7 +324,7 @@ void InputCECWorker::CecCommand(void *cbParam, const cec_command *command)
|
||||
|
||||
if (cec->m_verboseLogging)
|
||||
{
|
||||
QLOG_DEBUG() << "CecCommand button (Down= " << down << ")" << cec->getCommandParamsList(command);
|
||||
qDebug() << "CecCommand button (Down= " << down << ")" << cec->getCommandParamsList(command);
|
||||
}
|
||||
|
||||
if (command->parameters.size && down)
|
||||
@ -363,7 +363,7 @@ void InputCECWorker::CecCommand(void *cbParam, const cec_command *command)
|
||||
break;
|
||||
|
||||
case CEC_OPCODE_STANDBY:
|
||||
QLOG_DEBUG() << "CecCommand : Got a standby Request";
|
||||
qDebug() << "CecCommand : Got a standby Request";
|
||||
if ((SettingsComponent::Get().value(SETTINGS_SECTION_CEC, "suspendonstandby").toBool()) && PowerComponent::Get().canSuspend())
|
||||
{
|
||||
PowerComponent::Get().Suspend();
|
||||
@ -375,7 +375,7 @@ void InputCECWorker::CecCommand(void *cbParam, const cec_command *command)
|
||||
break;
|
||||
|
||||
default:
|
||||
QLOG_DEBUG() << "Unhandled CEC command " << command->opcode << ", " << cec->getCommandParamsList(command);
|
||||
qDebug() << "Unhandled CEC command " << command->opcode << ", " << cec->getCommandParamsList(command);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -390,21 +390,21 @@ void InputCECWorker::CecAlert(void *cbParam, const libcec_alert type, const libc
|
||||
switch (type)
|
||||
{
|
||||
case CEC_ALERT_SERVICE_DEVICE:
|
||||
QLOG_ERROR() << "libCEC : Alert CEC_ALERT_SERVICE_DEVICE";
|
||||
qCritical() << "libCEC : Alert CEC_ALERT_SERVICE_DEVICE";
|
||||
break;
|
||||
|
||||
case CEC_ALERT_CONNECTION_LOST:
|
||||
QLOG_ERROR() << "libCEC : Alert CEC_ALERT_CONNECTION_LOST";
|
||||
qCritical() << "libCEC : Alert CEC_ALERT_CONNECTION_LOST";
|
||||
reopen = true;
|
||||
break;
|
||||
|
||||
case CEC_ALERT_PERMISSION_ERROR:
|
||||
QLOG_ERROR() << "libCEC : Alert CEC_ALERT_PERMISSION_ERROR";
|
||||
qCritical() << "libCEC : Alert CEC_ALERT_PERMISSION_ERROR";
|
||||
reopen = true;
|
||||
break;
|
||||
|
||||
case CEC_ALERT_PORT_BUSY:
|
||||
QLOG_ERROR() << "libCEC : Alert CEC_ALERT_PORT_BUSY";
|
||||
qCritical() << "libCEC : Alert CEC_ALERT_PORT_BUSY";
|
||||
reopen = true;
|
||||
break;
|
||||
|
||||
@ -414,7 +414,7 @@ void InputCECWorker::CecAlert(void *cbParam, const libcec_alert type, const libc
|
||||
|
||||
if (reopen)
|
||||
{
|
||||
QLOG_DEBUG() << "libCEC : Reopenning adapter";
|
||||
qDebug() << "libCEC : Reopenning adapter";
|
||||
auto cec = static_cast<InputCECWorker*>(cbParam);
|
||||
if (cec)
|
||||
cec->closeAdapter();
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "QsLog.h"
|
||||
#include <QDebug>
|
||||
#include "InputComponent.h"
|
||||
#include "settings/SettingsComponent.h"
|
||||
#include "system/SystemComponent.h"
|
||||
@ -46,11 +46,11 @@ bool InputComponent::addInput(InputBase* base)
|
||||
{
|
||||
if (!base->initInput())
|
||||
{
|
||||
QLOG_WARN() << "Failed to init input:" << base->inputName();
|
||||
qWarning() << "Failed to init input:" << base->inputName();
|
||||
return false;
|
||||
}
|
||||
|
||||
QLOG_INFO() << "Successfully inited input:" << base->inputName();
|
||||
qInfo() << "Successfully inited input:" << base->inputName();
|
||||
m_inputs.push_back(base);
|
||||
|
||||
// we connect to the provider receivedInput signal, then we check if the name
|
||||
@ -65,7 +65,7 @@ bool InputComponent::addInput(InputBase* base)
|
||||
{
|
||||
if (!m_autoRepeatActions.isEmpty())
|
||||
{
|
||||
QLOG_DEBUG() << "Emit input action (autorepeat):" << m_autoRepeatActions;
|
||||
qDebug() << "Emit input action (autorepeat):" << m_autoRepeatActions;
|
||||
emit hostInput(m_autoRepeatActions);
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ void InputComponent::handleAction(const QString& action)
|
||||
hostArguments = argList.join(" ");
|
||||
}
|
||||
|
||||
QLOG_DEBUG() << "Got host command:" << hostCommand << "arguments:" << hostArguments;
|
||||
qDebug() << "Got host command:" << hostCommand << "arguments:" << hostArguments;
|
||||
if (m_hostCommands.contains(hostCommand))
|
||||
{
|
||||
ReceiverSlot* recvSlot = m_hostCommands.value(hostCommand);
|
||||
@ -126,12 +126,12 @@ void InputComponent::handleAction(const QString& action)
|
||||
{
|
||||
if (recvSlot->m_function)
|
||||
{
|
||||
QLOG_DEBUG() << "Invoking anonymous function";
|
||||
qDebug() << "Invoking anonymous function";
|
||||
recvSlot->m_function();
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_DEBUG() << "Invoking slot" << qPrintable(recvSlot->m_slot.data());
|
||||
qDebug() << "Invoking slot" << qPrintable(recvSlot->m_slot.data());
|
||||
QGenericArgument arg0 = QGenericArgument();
|
||||
|
||||
if (recvSlot->m_hasArguments)
|
||||
@ -140,14 +140,14 @@ void InputComponent::handleAction(const QString& action)
|
||||
if (!QMetaObject::invokeMethod(recvSlot->m_receiver, recvSlot->m_slot.data(),
|
||||
Qt::AutoConnection, arg0))
|
||||
{
|
||||
QLOG_ERROR() << "Invoking slot" << qPrintable(recvSlot->m_slot.data()) << "failed!";
|
||||
qCritical() << "Invoking slot" << qPrintable(recvSlot->m_slot.data()) << "failed!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_WARN() << "No such host command:" << hostCommand;
|
||||
qWarning() << "No such host command:" << hostCommand;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -155,7 +155,7 @@ void InputComponent::handleAction(const QString& action)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void InputComponent::remapInput(const QString &source, const QString &keycode, InputBase::InputkeyState keyState)
|
||||
{
|
||||
QLOG_DEBUG() << "Input received: source:" << source << "keycode:" << keycode << ":" << keyState;
|
||||
qDebug() << "Input received: source:" << source << "keycode:" << keycode << ":" << keyState;
|
||||
|
||||
emit receivedInput();
|
||||
|
||||
@ -175,7 +175,7 @@ void InputComponent::remapInput(const QString &source, const QString &keycode, I
|
||||
|
||||
m_currentLongPressAction.clear();
|
||||
|
||||
QLOG_DEBUG() << "Emit input action (" + type + "):" << action;
|
||||
qDebug() << "Emit input action (" + type + "):" << action;
|
||||
emit hostInput(QStringList{action});
|
||||
}
|
||||
|
||||
@ -225,12 +225,12 @@ void InputComponent::remapInput(const QString &source, const QString &keycode, I
|
||||
{
|
||||
if (SystemComponent::Get().isWebClientConnected())
|
||||
{
|
||||
QLOG_DEBUG() << "Emit input action:" << queuedActions;
|
||||
qDebug() << "Emit input action:" << queuedActions;
|
||||
emit hostInput(queuedActions);
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_DEBUG() << "Web Client has not connected, handling input in host instead.";
|
||||
qDebug() << "Web Client has not connected, handling input in host instead.";
|
||||
executeActions(queuedActions);
|
||||
}
|
||||
}
|
||||
@ -259,7 +259,7 @@ void InputComponent::registerHostCommand(const QString& command, QObject* receiv
|
||||
recvSlot->m_slot = QMetaObject::normalizedSignature(slot);
|
||||
recvSlot->m_hasArguments = false;
|
||||
|
||||
QLOG_DEBUG() << "Adding host command:" << qPrintable(command) << "mapped to"
|
||||
qDebug() << "Adding host command:" << qPrintable(command) << "mapped to"
|
||||
<< qPrintable(QString(receiver->metaObject()->className()) + "::" + recvSlot->m_slot);
|
||||
|
||||
m_hostCommands.insert(command, recvSlot);
|
||||
@ -268,16 +268,16 @@ void InputComponent::registerHostCommand(const QString& command, QObject* receiv
|
||||
auto slotWithoutArgs = QString("%1()").arg(QString::fromLatin1(recvSlot->m_slot)).toLatin1();
|
||||
if (recvSlot->m_receiver->metaObject()->indexOfMethod(slotWithArgs.data()) != -1)
|
||||
{
|
||||
QLOG_DEBUG() << "Host command maps to method with an argument.";
|
||||
qDebug() << "Host command maps to method with an argument.";
|
||||
recvSlot->m_hasArguments = true;
|
||||
}
|
||||
else if (recvSlot->m_receiver->metaObject()->indexOfMethod(slotWithoutArgs.data()) != -1)
|
||||
{
|
||||
QLOG_DEBUG() << "Host command maps to method without arguments.";
|
||||
qDebug() << "Host command maps to method without arguments.";
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "Slot for host command missing, or has incorrect signature!";
|
||||
qCritical() << "Slot for host command missing, or has incorrect signature!";
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ void InputComponent::registerHostCommand(const QString& command, std::function<v
|
||||
{
|
||||
auto recvSlot = new ReceiverSlot;
|
||||
recvSlot->m_function = function;
|
||||
QLOG_DEBUG() << "Adding host command:" << qPrintable(command) << "mapped to anonymous function";
|
||||
qDebug() << "Adding host command:" << qPrintable(command) << "mapped to anonymous function";
|
||||
m_hostCommands.insert(command, recvSlot);
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
#define KONVERGO_INPUTKEYBOARD_H
|
||||
|
||||
#include <QKeySequence>
|
||||
#include <QDebug>
|
||||
#include "InputComponent.h"
|
||||
#include "QsLog.h"
|
||||
|
||||
class InputKeyboard : public InputBase
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include "QsLog.h"
|
||||
#include <QDebug>
|
||||
#include "InputLIRC.h"
|
||||
|
||||
#define DEFAULT_LIRC_ADDRESS "/run/lirc/lircd"
|
||||
@ -67,19 +67,19 @@ bool InputLIRC::isConnected()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void InputLIRC::connected()
|
||||
{
|
||||
QLOG_INFO() << "LIRC socket connected ";
|
||||
qInfo() << "LIRC socket connected ";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void InputLIRC::disconnected()
|
||||
{
|
||||
QLOG_INFO() << "LIRC socket disconnected ";
|
||||
qInfo() << "LIRC socket disconnected ";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void InputLIRC::socketerror(QLocalSocket::LocalSocketError socketError)
|
||||
{
|
||||
QLOG_ERROR() << "LIRC Socket Error : " << socketError;
|
||||
qCritical() << "LIRC Socket Error : " << socketError;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -100,7 +100,7 @@ void InputLIRC::read(int handle)
|
||||
|
||||
int repeatCount = repeat.toInt();
|
||||
|
||||
QLOG_INFO() << "LIRC Got Key : " << command << ", repeat count:" << repeatCount
|
||||
qInfo() << "LIRC Got Key : " << command << ", repeat count:" << repeatCount
|
||||
<< ", from remote " << remote;
|
||||
|
||||
// we dont want to have all the IR Bursts when we press a key
|
||||
@ -112,6 +112,6 @@ void InputLIRC::read(int handle)
|
||||
}
|
||||
}
|
||||
else
|
||||
QLOG_ERROR() << "Unknown LIRC input: " << input;
|
||||
qCritical() << "Unknown LIRC input: " << input;
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QDebug>
|
||||
|
||||
#include "QsLog.h"
|
||||
#include "Paths.h"
|
||||
#include "utils/Utils.h"
|
||||
|
||||
@ -22,7 +22,7 @@ InputMapping::InputMapping(QObject *parent) : QObject(parent), m_sourceMatcher(f
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void InputMapping::dirChange()
|
||||
{
|
||||
QLOG_INFO() << "Change to user input path, reloading mappings.";
|
||||
qInfo() << "Change to user input path, reloading mappings.";
|
||||
loadMappings();
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ bool InputMapping::loadMappingFile(const QString& path, QPair<QString, QVariantM
|
||||
auto doc = Utils::OpenJsonDocument(path, &err);
|
||||
if (doc.isNull())
|
||||
{
|
||||
QLOG_WARN() << "Failed to parse input mapping file:" << path << "," << err.errorString();
|
||||
qWarning() << "Failed to parse input mapping file:" << path << "," << err.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -83,19 +83,19 @@ bool InputMapping::loadMappingFile(const QString& path, QPair<QString, QVariantM
|
||||
auto obj = doc.object();
|
||||
if (!obj.contains("name"))
|
||||
{
|
||||
QLOG_WARN() << "Missing elements 'name' from mapping file:" << path;
|
||||
qWarning() << "Missing elements 'name' from mapping file:" << path;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!obj.contains("idmatcher"))
|
||||
{
|
||||
QLOG_WARN() << "Missing element 'idmatcher' from mapping file:" << path;
|
||||
qWarning() << "Missing element 'idmatcher' from mapping file:" << path;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!obj.contains("mapping"))
|
||||
{
|
||||
QLOG_WARN() << "Missing element 'mapping' from mapping file:" << path;
|
||||
qWarning() << "Missing element 'mapping' from mapping file:" << path;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -103,14 +103,14 @@ bool InputMapping::loadMappingFile(const QString& path, QPair<QString, QVariantM
|
||||
return true;
|
||||
}
|
||||
|
||||
QLOG_WARN() << "Wrong format for file:" << path;
|
||||
qWarning() << "Wrong format for file:" << path;
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool InputMapping::loadMappingDirectory(const QString& path, bool copy)
|
||||
{
|
||||
QLOG_INFO() << "Loading inputmaps from:" << path;
|
||||
qInfo() << "Loading inputmaps from:" << path;
|
||||
QDirIterator it(path);
|
||||
while (it.hasNext())
|
||||
{
|
||||
|
@ -7,8 +7,8 @@
|
||||
//
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QDebug>
|
||||
#include "InputSDL.h"
|
||||
#include "QsLog.h"
|
||||
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
@ -22,7 +22,7 @@ bool InputSDLWorker::initialize()
|
||||
// init SDL
|
||||
if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
|
||||
{
|
||||
QLOG_ERROR() << "SDL failed to initialize : " << SDL_GetError();
|
||||
qCritical() << "SDL failed to initialize : " << SDL_GetError();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ void InputSDLWorker::close()
|
||||
{
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK))
|
||||
{
|
||||
QLOG_INFO() << "SDL is closing.";
|
||||
qInfo() << "SDL is closing.";
|
||||
|
||||
// we need to close all the openned joysticks here and then exit the thread
|
||||
for (int joyid = 0; joyid < m_joysticks.size(); joyid++)
|
||||
@ -95,14 +95,14 @@ void InputSDLWorker::run()
|
||||
|
||||
case SDL_JOYDEVICEADDED:
|
||||
{
|
||||
QLOG_INFO() << "SDL detected device was added.";
|
||||
qInfo() << "SDL detected device was added.";
|
||||
refreshJoystickList();
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYDEVICEREMOVED:
|
||||
{
|
||||
QLOG_INFO() << "SDL detected device was removed.";
|
||||
qInfo() << "SDL detected device was removed.";
|
||||
refreshJoystickList();
|
||||
break;
|
||||
}
|
||||
@ -150,7 +150,7 @@ void InputSDLWorker::run()
|
||||
auto axis = event.jaxis.axis;
|
||||
auto value = event.jaxis.value;
|
||||
|
||||
QLOG_DEBUG() << "JoyAxisMotion:" << axis << value;
|
||||
qDebug() << "JoyAxisMotion:" << axis << value;
|
||||
|
||||
// handle the Digital conversion of the analog axis
|
||||
if (std::abs(value) > 32768 / 2)
|
||||
@ -176,7 +176,7 @@ void InputSDLWorker::run()
|
||||
}
|
||||
default:
|
||||
{
|
||||
QLOG_WARN() << "Unhandled SDL event:" << event.type;
|
||||
qWarning() << "Unhandled SDL event:" << event.type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -204,7 +204,7 @@ void InputSDLWorker::refreshJoystickList()
|
||||
|
||||
// list all the joysticks and open them
|
||||
int numJoysticks = SDL_NumJoysticks();
|
||||
QLOG_INFO() << "SDL found " << numJoysticks << " joysticks";
|
||||
qInfo() << "SDL found " << numJoysticks << " joysticks";
|
||||
|
||||
for (int joyid = 0; joyid < numJoysticks; joyid++)
|
||||
{
|
||||
@ -213,7 +213,7 @@ void InputSDLWorker::refreshJoystickList()
|
||||
if (joystick)
|
||||
{
|
||||
int instanceid = SDL_JoystickInstanceID(joystick);
|
||||
QLOG_INFO() << "JoyStick #" << instanceid << " is " << SDL_JoystickName(joystick) << " with "
|
||||
qInfo() << "JoyStick #" << instanceid << " is " << SDL_JoystickName(joystick) << " with "
|
||||
<< SDL_JoystickNumButtons(joystick) << " buttons and " << SDL_JoystickNumAxes(joystick)
|
||||
<< "axes";
|
||||
m_joysticks[instanceid] = joystick;
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Created by Tobias Hieta on 24/08/15.
|
||||
//
|
||||
|
||||
#include <QDebug>
|
||||
#include "InputSocket.h"
|
||||
#include "QsLog.h"
|
||||
#include "Version.h"
|
||||
|
||||
#include <QDataStream>
|
||||
@ -31,11 +31,11 @@ void InputSocket::messageReceived(const QVariant& message)
|
||||
|
||||
if (!map.contains("client") || !map.contains("source") || !map.contains("keycode"))
|
||||
{
|
||||
QLOG_WARN() << "Got packet from client but it was missing the important fields";
|
||||
qWarning() << "Got packet from client but it was missing the important fields";
|
||||
return;
|
||||
}
|
||||
|
||||
QLOG_DEBUG() << "Input from client:" << map.value("client").toString() << " - " <<
|
||||
qDebug() << "Input from client:" << map.value("client").toString() << " - " <<
|
||||
map.value("source").toString() << map.value("keycode").toString();
|
||||
|
||||
emit receivedInput(map.value("source").toString(), map.value("keycode").toString(), KeyPressed);
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include <QDebug>
|
||||
#import "AppleRemoteDelegate.h"
|
||||
#import "InputAppleRemote.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
@implementation AppleRemoteDelegate
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -23,7 +22,7 @@
|
||||
[[HIDRemote sharedHIDRemote] setExclusiveLockLendingEnabled:YES];
|
||||
if (![[HIDRemote sharedHIDRemote] startRemoteControl:kHIDRemoteModeExclusive])
|
||||
{
|
||||
QLOG_ERROR() << "Failed to init AppleRemote";
|
||||
qCritical() << "Failed to init AppleRemote";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
// Created by Tobias Hieta on 21/08/15.
|
||||
//
|
||||
|
||||
#include <QDebug>
|
||||
#include "InputAppleMediaKeys.h"
|
||||
#include "SPMediaKeyTap.h"
|
||||
#include "QsLog.h"
|
||||
|
||||
#import <dlfcn.h>
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
if ([SPMediaKeyTap usesGlobalMediaKeyTap])
|
||||
[keyTap startWatchingMediaKeys];
|
||||
else
|
||||
QLOG_WARN() << "Could not grab global media keys";
|
||||
qWarning() << "Could not grab global media keys";
|
||||
}
|
||||
}
|
||||
return self;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <QDebug>
|
||||
#include "settings/SettingsComponent.h"
|
||||
#include "InputAppleRemote.h"
|
||||
#include "QsLog.h"
|
||||
|
||||
#include "HIDRemote.h"
|
||||
#include "AppleRemoteDelegate.h"
|
||||
@ -15,21 +15,21 @@ bool InputAppleRemote::initInput()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void InputAppleRemote::addRemoteFailed(const QString &error)
|
||||
{
|
||||
QLOG_ERROR() << error;
|
||||
qCritical() << error;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void InputAppleRemote::addRemote(const QString &name)
|
||||
{
|
||||
m_remotes << name;
|
||||
QLOG_DEBUG() << "Added remote:" << name;
|
||||
qDebug() << "Added remote:" << name;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void InputAppleRemote::removeRemote(const QString &name)
|
||||
{
|
||||
m_remotes.removeOne(name);
|
||||
QLOG_DEBUG() << "Remove remote:" << name;
|
||||
qDebug() << "Remove remote:" << name;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include <QtWebEngine/qtwebengineglobal.h>
|
||||
#include <QErrorMessage>
|
||||
#include <QCommandLineOption>
|
||||
#include <QDebug>
|
||||
|
||||
#include "shared/Names.h"
|
||||
#include "system/SystemComponent.h"
|
||||
#include "QsLog.h"
|
||||
#include "Paths.h"
|
||||
#include "player/CodecsComponent.h"
|
||||
#include "player/PlayerComponent.h"
|
||||
@ -251,7 +251,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
catch (FatalException& e)
|
||||
{
|
||||
QLOG_FATAL() << "Unhandled FatalException:" << qPrintable(e.message());
|
||||
qFatal("Unhandled FatalException: %s", qPrintable(e.message()));
|
||||
QApplication errApp(argc, argv);
|
||||
|
||||
auto msg = new ErrorMessage(e.message(), true);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "CodecsComponent.h"
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <Qt>
|
||||
#include <QDir>
|
||||
@ -28,8 +29,6 @@
|
||||
#include "shared/Paths.h"
|
||||
#include "PlayerComponent.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
#define countof(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
// For QVariant. Mysteriously makes Qt happy.
|
||||
@ -422,7 +421,7 @@ static bool probeDecoder(QString decoder, QString resourceName)
|
||||
{
|
||||
QResource resource(resourceName);
|
||||
|
||||
QLOG_DEBUG() << "Testing decoding of" << resource.fileName();
|
||||
qDebug() << "Testing decoding of" << resource.fileName();
|
||||
|
||||
if (!resource.isValid())
|
||||
return false;
|
||||
@ -457,7 +456,7 @@ static bool probeDecoder(QString decoder, QString resourceName)
|
||||
}
|
||||
}
|
||||
|
||||
QLOG_DEBUG() << "Result:" << result;
|
||||
qDebug() << "Result:" << result;
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -478,7 +477,7 @@ static void probeCodecs()
|
||||
else
|
||||
g_systemVideoDecoderWhitelist.remove("h264_mf");
|
||||
|
||||
QLOG_DEBUG() << "h264_mf max. resolution:" << g_mediaFoundationH264MaxResolution;
|
||||
qDebug() << "h264_mf max. resolution:" << g_mediaFoundationH264MaxResolution;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -539,12 +538,12 @@ static void updateCodecs()
|
||||
QStringList codecs;
|
||||
for (auto codec : install)
|
||||
codecs.append(codec.getMangledName());
|
||||
QLOG_INFO() << "Updating some codecs: " + codecs.join(", ");
|
||||
qInfo() << "Updating some codecs: " + codecs.join(", ");
|
||||
|
||||
auto fetcher = new CodecsFetcher();
|
||||
QObject::connect(fetcher, &CodecsFetcher::done, [](CodecsFetcher* sender)
|
||||
{
|
||||
QLOG_INFO() << "Codec update finished.";
|
||||
qInfo() << "Codec update finished.";
|
||||
sender->deleteLater();
|
||||
});
|
||||
fetcher->startCodecs = false;
|
||||
@ -587,7 +586,7 @@ static void deleteOldCodecs()
|
||||
if (entry.startsWith(QString("EasyAudioEncoder-") + STRINGIFY(EAE_VERSION) + "-"))
|
||||
continue;
|
||||
|
||||
QLOG_DEBUG() << "Deleting old directory: " << entryPath.absolutePath();
|
||||
qDebug() << "Deleting old directory: " << entryPath.absolutePath();
|
||||
entryPath.removeRecursively();
|
||||
}
|
||||
}
|
||||
@ -615,7 +614,7 @@ bool CodecsFetcher::codecNeedsDownload(const CodecDriver& codec)
|
||||
return false;
|
||||
if (!codec.external)
|
||||
{
|
||||
QLOG_ERROR() << "Codec" << codec.driver << "does not exist and is not downloadable.";
|
||||
qCritical() << "Codec" << codec.driver << "does not exist and is not downloadable.";
|
||||
return false;
|
||||
}
|
||||
for (int n = 0; n < m_Codecs.size(); n++)
|
||||
@ -626,11 +625,11 @@ bool CodecsFetcher::codecNeedsDownload(const CodecDriver& codec)
|
||||
QFile codecFile(codec.getPath());
|
||||
if (codecFile.exists())
|
||||
{
|
||||
QLOG_ERROR() << "Codec" << codec.driver << "exists on disk as" << codec.getPath()
|
||||
qCritical() << "Codec" << codec.driver << "exists on disk as" << codec.getPath()
|
||||
<< "but is not known as installed - broken codec?";
|
||||
if (!codecFile.remove())
|
||||
return false;
|
||||
QLOG_ERROR() << "Retrying download.";
|
||||
qCritical() << "Retrying download.";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -699,25 +698,25 @@ void CodecsFetcher::startNext()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool CodecsFetcher::processCodecInfoReply(const QVariant& context, const QByteArray& data)
|
||||
{
|
||||
QLOG_INFO() << "Got reply:" << QString::fromUtf8(data);
|
||||
qInfo() << "Got reply:" << QString::fromUtf8(data);
|
||||
|
||||
QDomDocument dom;
|
||||
if (!dom.setContent(data))
|
||||
{
|
||||
QLOG_ERROR() << "XML parsing error.";
|
||||
qCritical() << "XML parsing error.";
|
||||
return false;
|
||||
}
|
||||
|
||||
QDomNodeList list = dom.elementsByTagName("MediaContainer");
|
||||
if (list.count() != 1)
|
||||
{
|
||||
QLOG_ERROR() << "MediaContainer XML element not found.";
|
||||
qCritical() << "MediaContainer XML element not found.";
|
||||
return false;
|
||||
}
|
||||
list = dom.elementsByTagName("Codec");
|
||||
if (list.count() != 1)
|
||||
{
|
||||
QLOG_ERROR() << "Codec XML element not found.";
|
||||
qCritical() << "Codec XML element not found.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -725,7 +724,7 @@ bool CodecsFetcher::processCodecInfoReply(const QVariant& context, const QByteAr
|
||||
QString url = attrs.namedItem("url").toAttr().value();
|
||||
if (!url.size())
|
||||
{
|
||||
QLOG_ERROR() << "No URL found.";
|
||||
qCritical() << "No URL found.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -733,7 +732,7 @@ bool CodecsFetcher::processCodecInfoReply(const QVariant& context, const QByteAr
|
||||
m_currentHash = QByteArray::fromHex(hash.toUtf8());
|
||||
// it's hardcoded to SHA-1
|
||||
if (!m_currentHash.size()) {
|
||||
QLOG_ERROR() << "Hash value in unexpected format or missing:" << hash;
|
||||
qCritical() << "Hash value in unexpected format or missing:" << hash;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -748,7 +747,7 @@ void CodecsFetcher::codecInfoDownloadDone(QVariant userData, bool success, const
|
||||
{
|
||||
if (!success || !processCodecInfoReply(userData, data))
|
||||
{
|
||||
QLOG_ERROR() << "Codec download failed.";
|
||||
qCritical() << "Codec download failed.";
|
||||
startNext();
|
||||
}
|
||||
}
|
||||
@ -824,7 +823,7 @@ static bool extractZip(QString zip, QString dest)
|
||||
unzFile file = unzOpen2(zip.toUtf8().data(), &unzfilefuncs);
|
||||
if (!file)
|
||||
{
|
||||
QLOG_ERROR() << "could not open .zip file.";
|
||||
qCritical() << "could not open .zip file.";
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -832,13 +831,13 @@ static bool extractZip(QString zip, QString dest)
|
||||
int unzerr;
|
||||
if ((unzerr = unzGetGlobalInfo(file, &info)) != UNZ_OK)
|
||||
{
|
||||
QLOG_ERROR() << "unzGlobalInfo() failed with" << unzerr;
|
||||
qCritical() << "unzGlobalInfo() failed with" << unzerr;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((unzerr = unzGoToFirstFile(file)) != UNZ_OK)
|
||||
{
|
||||
QLOG_ERROR() << "unzGoToFirstFile() failed with" << unzerr;
|
||||
qCritical() << "unzGoToFirstFile() failed with" << unzerr;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -846,7 +845,7 @@ static bool extractZip(QString zip, QString dest)
|
||||
{
|
||||
if (n > 0 && (unzerr = unzGoToNextFile(file)) != UNZ_OK)
|
||||
{
|
||||
QLOG_ERROR() << "unzGoToNextFile() failed with" << unzerr;
|
||||
qCritical() << "unzGoToNextFile() failed with" << unzerr;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -855,13 +854,13 @@ static bool extractZip(QString zip, QString dest)
|
||||
|
||||
if ((unzerr = unzGetCurrentFileInfo(file, &finfo, filename, sizeof(filename), 0, 0, 0, 0)) != UNZ_OK)
|
||||
{
|
||||
QLOG_ERROR() << "unzGetCurrentFileInfo() failed with" << unzerr;
|
||||
qCritical() << "unzGetCurrentFileInfo() failed with" << unzerr;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((unzerr = unzOpenCurrentFile(file)) != UNZ_OK)
|
||||
{
|
||||
QLOG_ERROR() << "unzOpenCurrentFile() failed with" << unzerr;
|
||||
qCritical() << "unzOpenCurrentFile() failed with" << unzerr;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -874,7 +873,7 @@ static bool extractZip(QString zip, QString dest)
|
||||
QDir dir(dest + "/" + filename);
|
||||
if (!dir.mkpath("."))
|
||||
{
|
||||
QLOG_ERROR() << "could not create zip sub directory";
|
||||
qCritical() << "could not create zip sub directory";
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -890,7 +889,7 @@ static bool extractZip(QString zip, QString dest)
|
||||
QSaveFile out(writepath);
|
||||
if (!out.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QLOG_ERROR() << "could not open output file" << filename;
|
||||
qCritical() << "could not open output file" << filename;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -904,20 +903,20 @@ static bool extractZip(QString zip, QString dest)
|
||||
|
||||
if (read < 0)
|
||||
{
|
||||
QLOG_ERROR() << "error decompressing zip entry" << filename;
|
||||
qCritical() << "error decompressing zip entry" << filename;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (out.write(buf, read) != read)
|
||||
{
|
||||
QLOG_ERROR() << "error writing output file" << filename;
|
||||
qCritical() << "error writing output file" << filename;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (!out.commit())
|
||||
{
|
||||
QLOG_ERROR() << "error closing output file" << filename;
|
||||
qCritical() << "error closing output file" << filename;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -928,7 +927,7 @@ static bool extractZip(QString zip, QString dest)
|
||||
{
|
||||
if (!QFile::setPermissions(writepath, QFileDevice::Permissions(0x5145)))
|
||||
{
|
||||
QLOG_ERROR() << "could not set output executable bit on extracted file";
|
||||
qCritical() << "could not set output executable bit on extracted file";
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@ -958,7 +957,7 @@ void CodecsFetcher::processCodecDownloadDone(const QVariant& context, const QByt
|
||||
|
||||
if (hash != m_currentHash)
|
||||
{
|
||||
QLOG_ERROR() << "Checksum mismatch: got" << hash.toHex() << "expected" << m_currentHash.toHex();
|
||||
qCritical() << "Checksum mismatch: got" << hash.toHex() << "expected" << m_currentHash.toHex();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -966,11 +965,11 @@ void CodecsFetcher::processCodecDownloadDone(const QVariant& context, const QByt
|
||||
{
|
||||
QString dest = eaePrefixPath() + ".zip";
|
||||
|
||||
QLOG_INFO() << "Storing EAE as" << dest;
|
||||
qInfo() << "Storing EAE as" << dest;
|
||||
|
||||
if (!Utils::safelyWriteFile(dest, data))
|
||||
{
|
||||
QLOG_ERROR() << "Writing codec file failed.";
|
||||
qCritical() << "Writing codec file failed.";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -979,7 +978,7 @@ void CodecsFetcher::processCodecDownloadDone(const QVariant& context, const QByt
|
||||
|
||||
if (!extractZip(dest, eaePrefixPath()))
|
||||
{
|
||||
QLOG_ERROR() << "Could not extract zip.";
|
||||
qCritical() << "Could not extract zip.";
|
||||
dir.removeRecursively();
|
||||
return;
|
||||
}
|
||||
@ -990,11 +989,11 @@ void CodecsFetcher::processCodecDownloadDone(const QVariant& context, const QByt
|
||||
{
|
||||
CodecDriver codec = context.value<CodecDriver>();
|
||||
|
||||
QLOG_INFO() << "Storing codec as" << codec.getPath();
|
||||
qInfo() << "Storing codec as" << codec.getPath();
|
||||
|
||||
if (!Utils::safelyWriteFile(codec.getPath(), data))
|
||||
{
|
||||
QLOG_ERROR() << "Writing codec file failed.";
|
||||
qCritical() << "Writing codec file failed.";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1004,26 +1003,26 @@ void CodecsFetcher::processCodecDownloadDone(const QVariant& context, const QByt
|
||||
{
|
||||
if (Codecs::sameCodec(item, codec) && !item.present)
|
||||
{
|
||||
QLOG_ERROR() << "Codec could not be loaded after installing it.";
|
||||
qCritical() << "Codec could not be loaded after installing it.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QLOG_INFO() << "Codec download and installation succeeded.";
|
||||
qInfo() << "Codec download and installation succeeded.";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CodecsFetcher::codecDownloadDone(QVariant userData, bool success, const QByteArray& data)
|
||||
{
|
||||
QLOG_INFO() << "Codec request finished.";
|
||||
qInfo() << "Codec request finished.";
|
||||
if (success)
|
||||
{
|
||||
processCodecDownloadDone(userData, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "Codec download HTTP request failed.";
|
||||
qCritical() << "Codec download HTTP request failed.";
|
||||
}
|
||||
startNext();
|
||||
}
|
||||
@ -1039,19 +1038,19 @@ void CodecsFetcher::startEAE()
|
||||
connect(g_eaeProcess, &QProcess::stateChanged,
|
||||
[](QProcess::ProcessState s)
|
||||
{
|
||||
QLOG_INFO() << "EAE process state:" << s;
|
||||
qInfo() << "EAE process state:" << s;
|
||||
}
|
||||
);
|
||||
connect(g_eaeProcess, &QProcess::errorOccurred,
|
||||
[](QProcess::ProcessError e)
|
||||
{
|
||||
QLOG_INFO() << "EAE process error:" << e;
|
||||
qInfo() << "EAE process error:" << e;
|
||||
}
|
||||
);
|
||||
connect(g_eaeProcess, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
||||
[](int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
QLOG_INFO() << "EAE process finished:" << exitCode << exitStatus;
|
||||
qInfo() << "EAE process finished:" << exitCode << exitStatus;
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -1061,10 +1060,10 @@ void CodecsFetcher::startEAE()
|
||||
if (g_eaeProcess->program().size())
|
||||
{
|
||||
int exitCode = g_eaeProcess->exitStatus() == QProcess::NormalExit ? g_eaeProcess->exitCode() : -1;
|
||||
QLOG_ERROR() << "EAE died with exit code" << exitCode;
|
||||
qCritical() << "EAE died with exit code" << exitCode;
|
||||
}
|
||||
|
||||
QLOG_INFO() << "Starting EAE.";
|
||||
qInfo() << "Starting EAE.";
|
||||
|
||||
g_eaeProcess->setProgram(eaeBinaryPath());
|
||||
g_eaeProcess->setWorkingDirectory(g_eaeWatchFolder);
|
||||
@ -1086,7 +1085,7 @@ void CodecsFetcher::startEAE()
|
||||
{
|
||||
if (!dir.mkpath(folder))
|
||||
{
|
||||
QLOG_ERROR() << "Could not create watch folder";
|
||||
qCritical() << "Could not create watch folder";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1098,7 +1097,7 @@ void CodecsFetcher::startEAE()
|
||||
Downloader::Downloader(QVariant userData, const QUrl& url, const HeaderList& headers, QObject* parent)
|
||||
: QObject(parent), m_userData(userData), m_lastProgress(-1)
|
||||
{
|
||||
QLOG_INFO() << "HTTP request:" << url.toDisplayString();
|
||||
qInfo() << "HTTP request:" << url.toDisplayString();
|
||||
m_currentStartTime.start();
|
||||
|
||||
connect(&m_WebCtrl, &QNetworkAccessManager::finished, this, &Downloader::networkFinished);
|
||||
@ -1122,7 +1121,7 @@ void Downloader::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
if (m_lastProgress < 0 || progress > m_lastProgress + 10)
|
||||
{
|
||||
m_lastProgress = progress;
|
||||
QLOG_INFO() << "HTTP request at" << progress << "% (" << bytesReceived << "/" << bytesTotal << ")";
|
||||
qInfo() << "HTTP request at" << progress << "% (" << bytesReceived << "/" << bytesTotal << ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1130,7 +1129,7 @@ void Downloader::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Downloader::networkFinished(QNetworkReply* pReply)
|
||||
{
|
||||
QLOG_INFO() << "HTTP finished after" << (m_currentStartTime.elapsed() + 500) / 1000
|
||||
qInfo() << "HTTP finished after" << (m_currentStartTime.elapsed() + 500) / 1000
|
||||
<< "seconds for a request of" << pReply->size() << "bytes.";
|
||||
|
||||
if (pReply->error() == QNetworkReply::NoError)
|
||||
@ -1139,7 +1138,7 @@ void Downloader::networkFinished(QNetworkReply* pReply)
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "HTTP download error:" << pReply->errorString();
|
||||
qCritical() << "HTTP download error:" << pReply->errorString();
|
||||
emit done(m_userData, false, QByteArray());
|
||||
}
|
||||
pReply->deleteLater();
|
||||
@ -1216,11 +1215,11 @@ QList<CodecDriver> Codecs::determineRequiredCodecs(const PlaybackInfo& info)
|
||||
|
||||
bool needAC3Encoder = false;
|
||||
|
||||
QLOG_INFO() << "Using system audio decoders:" << useSystemAudioDecoders();
|
||||
QLOG_INFO() << "Using system video decoders:" << useSystemVideoDecoders();
|
||||
qInfo() << "Using system audio decoders:" << useSystemAudioDecoders();
|
||||
qInfo() << "Using system video decoders:" << useSystemVideoDecoders();
|
||||
|
||||
#if !defined(HAVE_CODEC_MANIFEST)
|
||||
QLOG_INFO() << "Not using on-demand codecs.";
|
||||
qInfo() << "Not using on-demand codecs.";
|
||||
#endif
|
||||
|
||||
for (auto stream : info.streams)
|
||||
@ -1229,7 +1228,7 @@ QList<CodecDriver> Codecs::determineRequiredCodecs(const PlaybackInfo& info)
|
||||
continue;
|
||||
if (!stream.codec.size())
|
||||
{
|
||||
QLOG_ERROR() << "unidentified codec";
|
||||
qCritical() << "unidentified codec";
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1253,7 +1252,7 @@ QList<CodecDriver> Codecs::determineRequiredCodecs(const PlaybackInfo& info)
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "no decoder for" << stream.codec;
|
||||
qCritical() << "no decoder for" << stream.codec;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1277,7 +1276,7 @@ QList<CodecDriver> Codecs::determineRequiredCodecs(const PlaybackInfo& info)
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "no AC3 encoder available";
|
||||
qCritical() << "no AC3 encoder available";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
#include <QSurfaceFormat>
|
||||
#include <QCoreApplication>
|
||||
#include <QOpenGLContext>
|
||||
#include <QDebug>
|
||||
|
||||
#include <mpv/client.h>
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
#include "QtHelper.h"
|
||||
#include "OpenGLDetect.h"
|
||||
@ -87,7 +87,7 @@ void detectOpenGLLate()
|
||||
QList<int> versions = { 3, 2 };
|
||||
for (auto version : versions)
|
||||
{
|
||||
QLOG_INFO() << "Trying GLES version" << version;
|
||||
qInfo() << "Trying GLES version" << version;
|
||||
QSurfaceFormat fmt = QSurfaceFormat::defaultFormat();
|
||||
fmt.setMajorVersion(version);
|
||||
#ifdef HAVE_OPTIMALORIENTATION
|
||||
@ -97,7 +97,7 @@ void detectOpenGLLate()
|
||||
ctx.setFormat(fmt);
|
||||
if (ctx.create())
|
||||
{
|
||||
QLOG_INFO() << "Using GLES version" << version;
|
||||
qInfo() << "Using GLES version" << version;
|
||||
QSurfaceFormat::setDefaultFormat(fmt);
|
||||
break;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QDebug>
|
||||
#include "display/DisplayComponent.h"
|
||||
#include "settings/SettingsComponent.h"
|
||||
#include "system/SystemComponent.h"
|
||||
@ -15,8 +16,6 @@
|
||||
#include "PlayerQuickItem.h"
|
||||
#include "input/InputComponent.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <shared/Paths.h>
|
||||
@ -237,7 +236,7 @@ bool PlayerComponent::componentInitialize()
|
||||
codecInfo += "(enc)";
|
||||
}
|
||||
}
|
||||
QLOG_INFO() << "Present codecs:" << qPrintable(codecInfo);
|
||||
qInfo() << "Present codecs:" << qPrintable(codecInfo);
|
||||
|
||||
connect(this, &PlayerComponent::onMpvEvents, this, &PlayerComponent::handleMpvEvents, Qt::QueuedConnection);
|
||||
emit onMpvEvents();
|
||||
@ -357,11 +356,11 @@ void PlayerComponent::streamSwitch()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool PlayerComponent::switchDisplayFrameRate()
|
||||
{
|
||||
QLOG_DEBUG() << "Video framerate:" << m_mediaFrameRate << "fps";
|
||||
qDebug() << "Video framerate:" << m_mediaFrameRate << "fps";
|
||||
|
||||
if (!SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "refreshrate.auto_switch").toBool())
|
||||
{
|
||||
QLOG_DEBUG() << "Not switching refresh-rate (disabled by settings).";
|
||||
qDebug() << "Not switching refresh-rate (disabled by settings).";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -371,13 +370,13 @@ bool PlayerComponent::switchDisplayFrameRate()
|
||||
#endif
|
||||
if (!fs)
|
||||
{
|
||||
QLOG_DEBUG() << "Not switching refresh-rate (not in fullscreen mode).";
|
||||
qDebug() << "Not switching refresh-rate (not in fullscreen mode).";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_mediaFrameRate < 1)
|
||||
{
|
||||
QLOG_DEBUG() << "Not switching refresh-rate (no known video framerate).";
|
||||
qDebug() << "Not switching refresh-rate (no known video framerate).";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -388,7 +387,7 @@ bool PlayerComponent::switchDisplayFrameRate()
|
||||
DisplayComponent* display = &DisplayComponent::Get();
|
||||
if (!display->switchToBestVideoMode(m_mediaFrameRate))
|
||||
{
|
||||
QLOG_DEBUG() << "Switching refresh-rate failed or unnecessary.";
|
||||
qDebug() << "Switching refresh-rate failed or unnecessary.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -449,29 +448,29 @@ void PlayerComponent::updatePlaybackState()
|
||||
{
|
||||
switch (newState) {
|
||||
case State::paused:
|
||||
QLOG_INFO() << "Entering state: paused";
|
||||
qInfo() << "Entering state: paused";
|
||||
emit paused();
|
||||
break;
|
||||
case State::playing:
|
||||
QLOG_INFO() << "Entering state: playing";
|
||||
qInfo() << "Entering state: playing";
|
||||
emit playing();
|
||||
break;
|
||||
case State::buffering:
|
||||
QLOG_INFO() << "Entering state: buffering";
|
||||
qInfo() << "Entering state: buffering";
|
||||
m_lastBufferingPercentage = -1; /* force update below */
|
||||
break;
|
||||
case State::finished:
|
||||
QLOG_INFO() << "Entering state: finished";
|
||||
qInfo() << "Entering state: finished";
|
||||
emit finished();
|
||||
emit stopped();
|
||||
break;
|
||||
case State::canceled:
|
||||
QLOG_INFO() << "Entering state: canceled";
|
||||
qInfo() << "Entering state: canceled";
|
||||
emit canceled();
|
||||
emit stopped();
|
||||
break;
|
||||
case State::error:
|
||||
QLOG_INFO() << ("Entering state: error (" + m_playbackError + ")");
|
||||
qInfo() << ("Entering state: error (" + m_playbackError + ")");
|
||||
emit error(m_playbackError);
|
||||
break;
|
||||
}
|
||||
@ -585,13 +584,13 @@ void PlayerComponent::handleMpvEvent(mpv_event *event)
|
||||
len -= 1;
|
||||
QString logline = QString::fromUtf8(msg->prefix) + ": " + QString::fromUtf8(msg->text, (int)len);
|
||||
if (msg->log_level >= MPV_LOG_LEVEL_V)
|
||||
QLOG_DEBUG() << qPrintable(logline);
|
||||
qDebug() << qPrintable(logline);
|
||||
else if (msg->log_level >= MPV_LOG_LEVEL_INFO)
|
||||
QLOG_INFO() << qPrintable(logline);
|
||||
qInfo() << qPrintable(logline);
|
||||
else if (msg->log_level >= MPV_LOG_LEVEL_WARN)
|
||||
QLOG_WARN() << qPrintable(logline);
|
||||
qWarning() << qPrintable(logline);
|
||||
else
|
||||
QLOG_ERROR() << qPrintable(logline);
|
||||
qCritical() << qPrintable(logline);
|
||||
break;
|
||||
}
|
||||
case MPV_EVENT_CLIENT_MESSAGE:
|
||||
@ -607,9 +606,9 @@ void PlayerComponent::handleMpvEvent(mpv_event *event)
|
||||
{
|
||||
// Calling this lambda will instruct mpv to continue loading the file.
|
||||
auto resume = [=] {
|
||||
QLOG_INFO() << "checking codecs";
|
||||
qInfo() << "checking codecs";
|
||||
startCodecsLoading([=] {
|
||||
QLOG_INFO() << "resuming loading";
|
||||
qInfo() << "resuming loading";
|
||||
mpv::qt::command(m_mpv, QStringList() << "hook-ack" << resumeId);
|
||||
});
|
||||
};
|
||||
@ -620,7 +619,7 @@ void PlayerComponent::handleMpvEvent(mpv_event *event)
|
||||
// to various strange OS-related reasons.
|
||||
// (Better hope the user doesn't try to exit Konvergo during mode change.)
|
||||
int pause = SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "refreshrate.delay").toInt() * 1000;
|
||||
QLOG_INFO() << "waiting" << pause << "msec after rate switch before loading";
|
||||
qInfo() << "waiting" << pause << "msec after rate switch before loading";
|
||||
QTimer::singleShot(pause, resume);
|
||||
}
|
||||
else
|
||||
@ -652,9 +651,9 @@ void PlayerComponent::handleMpvEvent(mpv_event *event)
|
||||
{
|
||||
// Calling this lambda will instruct mpv to continue loading the file.
|
||||
auto resume = [=] {
|
||||
QLOG_INFO() << "checking codecs";
|
||||
qInfo() << "checking codecs";
|
||||
startCodecsLoading([=] {
|
||||
QLOG_INFO() << "resuming loading";
|
||||
qInfo() << "resuming loading";
|
||||
mpv_hook_continue(m_mpv, id);
|
||||
});
|
||||
};
|
||||
@ -665,7 +664,7 @@ void PlayerComponent::handleMpvEvent(mpv_event *event)
|
||||
// to various strange OS-related reasons.
|
||||
// (Better hope the user doesn't try to exit Konvergo during mode change.)
|
||||
int pause = SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "refreshrate.delay").toInt() * 1000;
|
||||
QLOG_INFO() << "waiting" << pause << "msec after rate switch before loading";
|
||||
qInfo() << "waiting" << pause << "msec after rate switch before loading";
|
||||
QTimer::singleShot(pause, resume);
|
||||
}
|
||||
else
|
||||
@ -976,9 +975,9 @@ void PlayerComponent::checkCurrentAudioDevice(const QSet<QString>& old_devs, con
|
||||
QSet<QString> removed = old_devs - new_devs;
|
||||
QSet<QString> added = new_devs - old_devs;
|
||||
|
||||
QLOG_DEBUG() << "Audio devices removed:" << removed;
|
||||
QLOG_DEBUG() << "Audio devices added:" << added;
|
||||
QLOG_DEBUG() << "Audio device selected:" << userDevice;
|
||||
qDebug() << "Audio devices removed:" << removed;
|
||||
qDebug() << "Audio devices added:" << added;
|
||||
qDebug() << "Audio device selected:" << userDevice;
|
||||
|
||||
if (userDevice.length())
|
||||
{
|
||||
@ -1043,7 +1042,7 @@ void PlayerComponent::updateAudioDevice()
|
||||
|
||||
if (!m_audioDevices.contains(device))
|
||||
{
|
||||
QLOG_WARN() << "Not using audio device" << device << "because it's not present.";
|
||||
qWarning() << "Not using audio device" << device << "because it's not present.";
|
||||
device = "auto";
|
||||
}
|
||||
|
||||
@ -1133,7 +1132,7 @@ void PlayerComponent::setAudioConfiguration()
|
||||
layout.toString(),
|
||||
passthroughCodecs.isEmpty() ? "none" : passthroughCodecs,
|
||||
m_doAc3Transcoding ? "yes" : "no");
|
||||
QLOG_INFO() << qPrintable(audioConfig);
|
||||
qInfo() << qPrintable(audioConfig);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -1270,7 +1269,7 @@ void PlayerComponent::initializeCodecSupport()
|
||||
ok = !!strstr(res, "=enabled");
|
||||
#endif
|
||||
m_codecSupport[name] = ok;
|
||||
QLOG_INFO() << "Codec" << name << (ok ? "present" : "disabled");
|
||||
qInfo() << "Codec" << name << (ok ? "present" : "disabled");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1389,7 +1388,7 @@ PlaybackInfo PlayerComponent::getPlaybackInfo()
|
||||
if (streamInfoMap["index"].toInt(&ok) == index && ok)
|
||||
{
|
||||
stream.profile = streamInfoMap["profile"].toString();
|
||||
QLOG_DEBUG() << "h264profile:" << stream.profile;
|
||||
qDebug() << "h264profile:" << stream.profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include <mpv/render_gl.h>
|
||||
|
||||
#include "QsLog.h"
|
||||
#include "utils/Utils.h"
|
||||
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
//
|
||||
// Created by Tobias Hieta on 25/03/15.
|
||||
//
|
||||
|
||||
#include "PowerComponent.h"
|
||||
#include "input/InputComponent.h"
|
||||
#include "settings/SettingsComponent.h"
|
||||
@ -32,7 +31,7 @@ PowerComponent& PowerComponent::Get()
|
||||
static PowerComponentWin instance;
|
||||
return instance;
|
||||
#else
|
||||
QLOG_WARN() << "Could not find a power component matching this platform. OS screensaver control disabled.";
|
||||
qWarning() << "Could not find a power component matching this platform. OS screensaver control disabled.";
|
||||
|
||||
static PowerComponent instance;
|
||||
return instance;
|
||||
@ -50,12 +49,12 @@ void PowerComponent::setScreensaverEnabled(bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
QLOG_DEBUG() << "Enabling OS screensaver";
|
||||
qDebug() << "Enabling OS screensaver";
|
||||
doEnableScreensaver();
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_DEBUG() << "Disabling OS screensaver";
|
||||
qDebug() << "Disabling OS screensaver";
|
||||
doDisableScreensaver();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef POWERMANAGER
|
||||
#define POWERMANAGER
|
||||
|
||||
#include <QsLog.h>
|
||||
#include <QDebug>
|
||||
#include "ComponentManager.h"
|
||||
|
||||
class PowerComponent : public ComponentBase
|
||||
|
@ -42,19 +42,19 @@ bool PowerComponentDBus::callPowerMethod(QString method)
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "callPowerMethod : Error while calling" << method << ":"
|
||||
qCritical() << "callPowerMethod : Error while calling" << method << ":"
|
||||
<< reply.error().message();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "callPowerMethod : failed to retrieve interface.";
|
||||
qCritical() << "callPowerMethod : failed to retrieve interface.";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "callPowerMethod : could not find system bus";
|
||||
qCritical() << "callPowerMethod : could not find system bus";
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -78,19 +78,19 @@ bool PowerComponentDBus::isPowerMethodAvailable(QString method)
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "isPowerMethodAvailable : Error while calling" << method << ":"
|
||||
qCritical() << "isPowerMethodAvailable : Error while calling" << method << ":"
|
||||
<< reply.error().message();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "isPowerMethodAvailable : failed to retrieve interface.";
|
||||
qCritical() << "isPowerMethodAvailable : failed to retrieve interface.";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "isPowerMethodAvailable : could not find system bus";
|
||||
qCritical() << "isPowerMethodAvailable : could not find system bus";
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -100,7 +100,7 @@ void PowerComponentDBus::doDisableScreensaver()
|
||||
{
|
||||
if (screensaver_inhibit_cookie)
|
||||
{
|
||||
QLOG_INFO() << "doDisableScreensaver : already disabled.";
|
||||
qInfo() << "doDisableScreensaver : already disabled.";
|
||||
return;
|
||||
}
|
||||
if (QDBusConnection::systemBus().isConnected())
|
||||
@ -117,18 +117,18 @@ void PowerComponentDBus::doDisableScreensaver()
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "doDisableScreensaver : Error while calling UnInhibit:"
|
||||
qCritical() << "doDisableScreensaver : Error while calling UnInhibit:"
|
||||
<< reply.error().message();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "doDisableScreensaver : failed to retrieve interface.";
|
||||
qCritical() << "doDisableScreensaver : failed to retrieve interface.";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "doDisableScreensaver : could not find system bus";
|
||||
qCritical() << "doDisableScreensaver : could not find system bus";
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ void PowerComponentDBus::doEnableScreensaver()
|
||||
{
|
||||
if (!screensaver_inhibit_cookie)
|
||||
{
|
||||
QLOG_INFO() << "doEnableScreensaver : already enabled.";
|
||||
qInfo() << "doEnableScreensaver : already enabled.";
|
||||
return;
|
||||
}
|
||||
if (QDBusConnection::systemBus().isConnected())
|
||||
@ -154,18 +154,18 @@ void PowerComponentDBus::doEnableScreensaver()
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "doEnableScreensaver : Error while calling UnInhibit:"
|
||||
qCritical() << "doEnableScreensaver : Error while calling UnInhibit:"
|
||||
<< reply.error().message();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "doEnableScreensaver : failed to retrieve interface.";
|
||||
qCritical() << "doEnableScreensaver : failed to retrieve interface.";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "doEnableScreensaver : could not find system bus";
|
||||
qCritical() << "doEnableScreensaver : could not find system bus";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,9 +28,9 @@ bool PowerComponentMac::PowerOff()
|
||||
{
|
||||
OSErr error = OSXUtils::SendAppleEventToSystemProcess(kAEShutDown);
|
||||
if (error == noErr)
|
||||
QLOG_DEBUG() << "Computer is going to shutdown!";
|
||||
qDebug() << "Computer is going to shutdown!";
|
||||
else
|
||||
QLOG_DEBUG() << "Computer wouldn't shutdown!";
|
||||
qDebug() << "Computer wouldn't shutdown!";
|
||||
|
||||
return (error == noErr);
|
||||
}
|
||||
@ -41,9 +41,9 @@ bool PowerComponentMac::Reboot()
|
||||
{
|
||||
OSErr error = OSXUtils::SendAppleEventToSystemProcess(kAERestart);
|
||||
if (error == noErr)
|
||||
QLOG_DEBUG() << "Computer is going to reboot!";
|
||||
qDebug() << "Computer is going to reboot!";
|
||||
else
|
||||
QLOG_DEBUG() << "Computer wouldn't reboot!";
|
||||
qDebug() << "Computer wouldn't reboot!";
|
||||
|
||||
return (error == noErr);
|
||||
}
|
||||
@ -53,9 +53,9 @@ bool PowerComponentMac::Suspend()
|
||||
{
|
||||
OSErr error = OSXUtils::SendAppleEventToSystemProcess(kAESleep);
|
||||
if (error == noErr)
|
||||
QLOG_DEBUG() << "Computer is going to sleep!";
|
||||
qDebug() << "Computer is going to sleep!";
|
||||
else
|
||||
QLOG_DEBUG() << "Computer wouldn't sleep!";
|
||||
qDebug() << "Computer wouldn't sleep!";
|
||||
|
||||
return (error == noErr);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "PowerComponentX11.h"
|
||||
#include "QsLog.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
PowerComponentX11::PowerComponentX11() : PowerComponent(0)
|
||||
@ -37,7 +36,7 @@ void PowerComponentX11::onProcessFinished(int exitCode, QProcess::ExitStatus exi
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void PowerComponentX11::onProcessError(QProcess::ProcessError error)
|
||||
{
|
||||
QLOG_ERROR() << "Disabling screensaver is not working. Make sure xdg-screensaver is installed.";
|
||||
qCritical() << "Disabling screensaver is not working. Make sure xdg-screensaver is installed.";
|
||||
m_broken = true;
|
||||
onProcessFinished(-1, QProcess::CrashExit);
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include "SettingsComponent.h"
|
||||
#include "SettingsSection.h"
|
||||
#include "Paths.h"
|
||||
#include "utils/Utils.h"
|
||||
#include "QsLog.h"
|
||||
#include "AudioSettingsController.h"
|
||||
#include "Names.h"
|
||||
|
||||
@ -37,7 +38,7 @@ void SettingsComponent::cycleSettingCommand(const QString& args)
|
||||
QStringList sub = settingName.split(".");
|
||||
if (sub.size() != 2)
|
||||
{
|
||||
QLOG_ERROR() << "Setting must be in the form section.name but got:" << settingName;
|
||||
qCritical() << "Setting must be in the form section.name but got:" << settingName;
|
||||
return;
|
||||
}
|
||||
QString sectionID = sub[0];
|
||||
@ -45,7 +46,7 @@ void SettingsComponent::cycleSettingCommand(const QString& args)
|
||||
SettingsSection* section = getSection(sectionID);
|
||||
if (!section)
|
||||
{
|
||||
QLOG_ERROR() << "Section" << sectionID << "is unknown";
|
||||
qCritical() << "Section" << sectionID << "is unknown";
|
||||
return;
|
||||
}
|
||||
QVariantList values = section->possibleValues(valueName);
|
||||
@ -59,13 +60,13 @@ void SettingsComponent::cycleSettingCommand(const QString& args)
|
||||
QVariant currentValue = section->value(valueName);
|
||||
auto nextValue = currentValue.toBool() ? false : true;
|
||||
setValue(sectionID, valueName, nextValue);
|
||||
QLOG_DEBUG() << "Setting" << settingName << "to " << (nextValue ? "Enabled" : "Disabled");
|
||||
qDebug() << "Setting" << settingName << "to " << (nextValue ? "Enabled" : "Disabled");
|
||||
emit SystemComponent::Get().settingsMessage(valueName, nextValue ? "Enabled" : "Disabled");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "Setting" << settingName << "is unknown or is not cycleable.";
|
||||
qCritical() << "Setting" << settingName << "is unknown or is not cycleable.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -83,7 +84,7 @@ void SettingsComponent::cycleSettingCommand(const QString& args)
|
||||
nextValueIndex = 0;
|
||||
auto nextSetting = values[nextValueIndex].toMap();
|
||||
auto nextValue = nextSetting["value"];
|
||||
QLOG_DEBUG() << "Setting" << settingName << "to" << nextValue;
|
||||
qDebug() << "Setting" << settingName << "to" << nextValue;
|
||||
setValue(sectionID, valueName, nextValue);
|
||||
emit SystemComponent::Get().settingsMessage(valueName, nextSetting["title"].toString());
|
||||
}
|
||||
@ -94,7 +95,7 @@ void SettingsComponent::setSettingCommand(const QString& args)
|
||||
int spaceIndex = args.indexOf(" ");
|
||||
if (spaceIndex < 0)
|
||||
{
|
||||
QLOG_ERROR() << "No value provided to settings set command.";
|
||||
qCritical() << "No value provided to settings set command.";
|
||||
return;
|
||||
}
|
||||
QString settingName = args.mid(0, spaceIndex);
|
||||
@ -102,7 +103,7 @@ void SettingsComponent::setSettingCommand(const QString& args)
|
||||
int subIndex = settingName.indexOf(".");
|
||||
if (subIndex < 0 || subIndex == args.size() - 1)
|
||||
{
|
||||
QLOG_ERROR() << "Setting must be in the form section.name but got:" << settingName;
|
||||
qCritical() << "Setting must be in the form section.name but got:" << settingName;
|
||||
return;
|
||||
}
|
||||
QString sectionID = settingName.mid(0, subIndex);
|
||||
@ -110,7 +111,7 @@ void SettingsComponent::setSettingCommand(const QString& args)
|
||||
SettingsSection* section = getSection(sectionID);
|
||||
if (!section)
|
||||
{
|
||||
QLOG_ERROR() << "Section" << sectionID << "is unknown";
|
||||
qCritical() << "Section" << sectionID << "is unknown";
|
||||
return;
|
||||
}
|
||||
QString jsonString = "{\"value\": " + settingValue + "}";
|
||||
@ -119,10 +120,10 @@ void SettingsComponent::setSettingCommand(const QString& args)
|
||||
printf("val: '%s'\n", settingValue.toUtf8().data());
|
||||
if (!value.isValid())
|
||||
{
|
||||
QLOG_ERROR() << "Invalid settings value:" << settingValue << "(if it's a string, make sure to quote it)";
|
||||
qCritical() << "Invalid settings value:" << settingValue << "(if it's a string, make sure to quote it)";
|
||||
return;
|
||||
}
|
||||
QLOG_DEBUG() << "Setting" << settingName << "to" << value;
|
||||
qDebug() << "Setting" << settingName << "to" << value;
|
||||
setValue(sectionID, valueName, value);
|
||||
emit SystemComponent::Get().settingsMessage(valueName, value.toString());
|
||||
}
|
||||
@ -133,11 +134,11 @@ void SettingsComponent::updatePossibleValues(const QString §ionID, const QSt
|
||||
SettingsSection* section = getSection(sectionID);
|
||||
if (!section)
|
||||
{
|
||||
QLOG_ERROR() << "Section" << sectionID << "is unknown";
|
||||
qCritical() << "Section" << sectionID << "is unknown";
|
||||
return;
|
||||
}
|
||||
section->updatePossibleValues(key, possibleValues);
|
||||
QLOG_DEBUG() << "Updated possible values for:" << key << "to" << possibleValues;
|
||||
qDebug() << "Updated possible values for:" << key << "to" << possibleValues;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -169,7 +170,7 @@ static void writeFile(const QString& filename, const QByteArray& data)
|
||||
file.write(data);
|
||||
if (!file.commit())
|
||||
{
|
||||
QLOG_ERROR() << "Could not write" << filename;
|
||||
qCritical() << "Could not write" << filename;
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,7 +186,7 @@ static QJsonObject loadJson(const QString& filename)
|
||||
QJsonDocument json = Utils::OpenJsonDocument(filename, &err);
|
||||
if (json.isNull())
|
||||
{
|
||||
QLOG_ERROR() << "Could not open" << filename << "due to" << err.errorString();
|
||||
qCritical() << "Could not open" << filename << "due to" << err.errorString();
|
||||
}
|
||||
return json.object();
|
||||
}
|
||||
@ -234,9 +235,9 @@ void SettingsComponent::loadConf(const QString& path, bool storage)
|
||||
QFile::remove(backup);
|
||||
QFile::rename(path, backup);
|
||||
if (version == 0)
|
||||
QLOG_ERROR() << "Could not read config file.";
|
||||
qCritical() << "Could not read config file.";
|
||||
else
|
||||
QLOG_ERROR() << "Config version is" << version << "but" << m_settingsVersion << "expected. Moving old config to" << backup;
|
||||
qCritical() << "Config version is" << version << "but" << m_settingsVersion << "expected. Moving old config to" << backup;
|
||||
// Overwrite/create it with the defaults.
|
||||
if (storage)
|
||||
saveStorage();
|
||||
@ -261,7 +262,7 @@ void SettingsComponent::loadConf(const QString& path, bool storage)
|
||||
}
|
||||
else if (!sec)
|
||||
{
|
||||
QLOG_ERROR() << "Trying to load section:" << section << "from config file, but we don't want that.";
|
||||
qCritical() << "Trying to load section:" << section << "from config file, but we don't want that.";
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -287,7 +288,7 @@ void SettingsComponent::saveSettings()
|
||||
{
|
||||
if (m_oldestPreviousVersion.isEmpty())
|
||||
{
|
||||
QLOG_ERROR() << "Not writing settings: uninitialized.\n";
|
||||
qCritical() << "Not writing settings: uninitialized.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -337,7 +338,7 @@ QVariant SettingsComponent::value(const QString& sectionID, const QString &key)
|
||||
SettingsSection* section = getSection(sectionID);
|
||||
if (!section)
|
||||
{
|
||||
QLOG_ERROR() << "Section" << sectionID << "is unknown";
|
||||
qCritical() << "Section" << sectionID << "is unknown";
|
||||
return QVariant();
|
||||
}
|
||||
return section->value(key);
|
||||
@ -349,7 +350,7 @@ void SettingsComponent::setValue(const QString& sectionID, const QString &key, c
|
||||
SettingsSection* section = getSection(sectionID);
|
||||
if (!section)
|
||||
{
|
||||
QLOG_ERROR() << "Section" << sectionID << "is unknown";
|
||||
qCritical() << "Section" << sectionID << "is unknown";
|
||||
return;
|
||||
}
|
||||
section->setValue(key, value);
|
||||
@ -390,7 +391,7 @@ void SettingsComponent::setValues(const QVariantMap& options)
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_WARN() << "the values sent was not a map, string or empty value. it will be ignored";
|
||||
qWarning() << "the values sent was not a map, string or empty value. it will be ignored";
|
||||
|
||||
// return so we don't call save()
|
||||
return;
|
||||
@ -474,13 +475,13 @@ bool SettingsComponent::loadDescription()
|
||||
auto doc = Utils::OpenJsonDocument(":/settings/settings_description.json", &err);
|
||||
if (doc.isNull())
|
||||
{
|
||||
QLOG_ERROR() << "Failed to read settings description:" << err.errorString();
|
||||
qCritical() << "Failed to read settings description:" << err.errorString();
|
||||
throw FatalException("Failed to read settings description!");
|
||||
}
|
||||
|
||||
if (!doc.isArray())
|
||||
{
|
||||
QLOG_ERROR() << "The object needs to be an array";
|
||||
qCritical() << "The object needs to be an array";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -490,14 +491,14 @@ bool SettingsComponent::loadDescription()
|
||||
{
|
||||
if (!val.isObject())
|
||||
{
|
||||
QLOG_ERROR() << "Hoped to find sections in the root array, but they where not JSON objects";
|
||||
qCritical() << "Hoped to find sections in the root array, but they where not JSON objects";
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonObject section = val.toObject();
|
||||
if (!section.contains("section"))
|
||||
{
|
||||
QLOG_ERROR() << "A section needs to contain the section keyword.";
|
||||
qCritical() << "A section needs to contain the section keyword.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -516,7 +517,7 @@ void SettingsComponent::parseSection(const QJsonObject& sectionObject)
|
||||
QString sectionName = sectionObject.value("section").toString();
|
||||
if (!sectionObject.contains("values") || !sectionObject.value("values").isArray())
|
||||
{
|
||||
QLOG_ERROR() << "section object:" << sectionName << "did not contain a values array";
|
||||
qCritical() << "section object:" << sectionName << "did not contain a values array";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -728,7 +729,7 @@ QString SettingsComponent::getWebClientUrl(bool desktop)
|
||||
url = "file:///" + path;
|
||||
}
|
||||
|
||||
QLOG_DEBUG() << "Using web-client URL: " << url;
|
||||
qDebug() << "Using web-client URL: " << url;
|
||||
|
||||
return url;
|
||||
}
|
||||
@ -771,7 +772,7 @@ bool SettingsComponent::ignoreSSLErrors()
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
void SettingsComponent::setCommandLineValues(const QStringList& values)
|
||||
{
|
||||
QLOG_DEBUG() << values;
|
||||
qDebug() << values;
|
||||
|
||||
for (const QString& value : values)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <QDebug>
|
||||
#include "SettingsSection.h"
|
||||
#include "QsLog.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
SettingsSection::SettingsSection(const QString& sectionID, quint8 platforms, int _orderIndex, QObject* parent)
|
||||
@ -13,7 +13,7 @@ void SettingsSection::registerSetting(SettingsValue* value)
|
||||
{
|
||||
if (m_values.contains(value->key()))
|
||||
{
|
||||
QLOG_WARN() << QString("Trying to register %1.%2 multiple times").arg(m_sectionID).arg(value->key());
|
||||
qWarning() << QString("Trying to register %1.%2 multiple times").arg(m_sectionID).arg(value->key());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ QVariant SettingsSection::defaultValue(const QString& key)
|
||||
if (m_values.contains(key))
|
||||
return m_values[key]->defaultValue();
|
||||
|
||||
QLOG_WARN() << "Looking for defaultValue:" << key << "in section:" << m_sectionID << "but it can't be found";
|
||||
qWarning() << "Looking for defaultValue:" << key << "in section:" << m_sectionID << "but it can't be found";
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ QVariant SettingsSection::value(const QString& key)
|
||||
if (m_values.contains(key))
|
||||
return m_values[key]->value();
|
||||
|
||||
QLOG_WARN() << "Looking for value:" << key << "in section:" << m_sectionID << "but it can't be found";
|
||||
qWarning() << "Looking for value:" << key << "in section:" << m_sectionID << "but it can't be found";
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
#include "SettingsValue.h"
|
||||
#include "SettingsComponent.h"
|
||||
#include "QsLog.h"
|
||||
|
||||
class SettingsSection : public QObject
|
||||
{
|
||||
|
@ -2,9 +2,10 @@
|
||||
// Created by Tobias Hieta on 30/08/15.
|
||||
//
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include "LocalJsonServer.h"
|
||||
#include "Paths.h"
|
||||
#include "QsLog.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
LocalJsonServer::LocalJsonServer(const QString& serverName, QObject* parent) : QObject(parent)
|
||||
@ -26,11 +27,11 @@ bool LocalJsonServer::listen()
|
||||
continue;
|
||||
}
|
||||
|
||||
QLOG_WARN() << "Failed to listen to local socket:" << m_server->errorString();
|
||||
qWarning() << "Failed to listen to local socket:" << m_server->errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
QLOG_INFO() << "Listening to socket:" << m_serverName;
|
||||
qInfo() << "Listening to socket:" << m_serverName;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -90,7 +91,7 @@ QVariantList LocalJsonServer::readFromSocket(QLocalSocket* socket)
|
||||
QJsonDocument doc = QJsonDocument::fromJson(data, &err);
|
||||
if (doc.isNull())
|
||||
{
|
||||
QLOG_WARN() << "Failed to parse message from client:" << err.errorString();
|
||||
qWarning() << "Failed to parse message from client:" << err.errorString();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include <QGuiApplication>
|
||||
#include <QsLog.h>
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#include <QDebug>
|
||||
#include "Names.h"
|
||||
#include "Version.h"
|
||||
|
||||
@ -19,7 +19,7 @@ static QDir writableLocation(QStandardPaths::StandardLocation loc)
|
||||
QDir d(QStandardPaths::writableLocation(loc));
|
||||
if (!d.mkpath(d.absolutePath() + "/" + Names::MainName()))
|
||||
{
|
||||
QLOG_WARN() << "Failed to create directory:" << d.absolutePath();
|
||||
qWarning() << "Failed to create directory:" << d.absolutePath();
|
||||
return QDir();
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ QString Paths::soundsPath(const QString& sound)
|
||||
f = QFileInfo(":/sounds/" + sound);
|
||||
if (!f.exists())
|
||||
{
|
||||
QLOG_WARN() << "Can't find sound:" << sound;
|
||||
qWarning() << "Can't find sound:" << sound;
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
@ -9,17 +9,18 @@
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QDebug>
|
||||
|
||||
#include "input/InputComponent.h"
|
||||
#include "SystemComponent.h"
|
||||
#include "Version.h"
|
||||
#include "QsLog.h"
|
||||
#include "settings/SettingsComponent.h"
|
||||
#include "ui/KonvergoWindow.h"
|
||||
#include "settings/SettingsSection.h"
|
||||
#include "Paths.h"
|
||||
#include "Names.h"
|
||||
#include "utils/Utils.h"
|
||||
#include "utils/Log.h"
|
||||
|
||||
#define MOUSE_TIMEOUT 5 * 1000
|
||||
|
||||
@ -153,7 +154,7 @@ QVariantMap SystemComponent::systemInformation() const
|
||||
info["version"] = Version::GetVersionString();
|
||||
info["productid"] = productid;
|
||||
|
||||
QLOG_DEBUG() << QString(
|
||||
qDebug() << QString(
|
||||
"System Information : build(%1)-arch(%2).dist(%3).version(%4).productid(%5)")
|
||||
.arg(build)
|
||||
.arg(arch)
|
||||
@ -179,8 +180,8 @@ void SystemComponent::restart()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void SystemComponent::info(QString text)
|
||||
{
|
||||
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::InfoLevel)
|
||||
QsLogging::Logger::Helper(QsLogging::InfoLevel).stream() << "JS:" << qPrintable(text);
|
||||
if (Log::ShouldLogInfo())
|
||||
qInfo() << "JS:" << qPrintable(text);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -293,27 +294,27 @@ void SystemComponent::runUserScript(QString script)
|
||||
{
|
||||
if (!QFileInfo(scriptFile).isExecutable())
|
||||
{
|
||||
QLOG_WARN() << "Script:" << script << "is not executable";
|
||||
qWarning() << "Script:" << script << "is not executable";
|
||||
return;
|
||||
}
|
||||
|
||||
QLOG_INFO() << "Running script:" << scriptPath;
|
||||
qInfo() << "Running script:" << scriptPath;
|
||||
|
||||
if (QProcess::startDetached(scriptPath, QStringList()))
|
||||
QLOG_DEBUG() << "Script started successfully";
|
||||
qDebug() << "Script started successfully";
|
||||
else
|
||||
QLOG_WARN() << "Error running script:" << scriptPath;
|
||||
qWarning() << "Error running script:" << scriptPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_WARN() << "Could not find script:" << scriptPath;
|
||||
qWarning() << "Could not find script:" << scriptPath;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
void SystemComponent::hello(const QString& version)
|
||||
{
|
||||
QLOG_DEBUG() << QString("Web-client (%1) fully inited.").arg(version);
|
||||
qDebug() << QString("Web-client (%1) fully inited.").arg(version);
|
||||
m_webClientVersion = version;
|
||||
}
|
||||
|
||||
@ -321,7 +322,7 @@ void SystemComponent::hello(const QString& version)
|
||||
QString SystemComponent::getNativeShellScript()
|
||||
{
|
||||
auto path = SettingsComponent::Get().getExtensionPath();
|
||||
QLOG_DEBUG() << QString("Using path for extension: %1").arg(path);
|
||||
qDebug() << QString("Using path for extension: %1").arg(path);
|
||||
|
||||
QFile file {path + "nativeshell.js"};
|
||||
file.open(QIODevice::ReadOnly);
|
||||
@ -344,7 +345,7 @@ void SystemComponent::checkForUpdates()
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
QString checkUrl = "https://github.com/jellyfin/jellyfin-media-player/releases/latest";
|
||||
QUrl qCheckUrl = QUrl(checkUrl);
|
||||
QLOG_DEBUG() << QString("Checking URL for updates: %1").arg(checkUrl);
|
||||
qDebug() << QString("Checking URL for updates: %1").arg(checkUrl);
|
||||
QNetworkRequest req(qCheckUrl);
|
||||
|
||||
connect(manager, &QNetworkAccessManager::finished, this, &SystemComponent::updateInfoHandler);
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "settings/SettingsSection.h"
|
||||
#include "OESystemComponent.h"
|
||||
#include "SystemdManager.h"
|
||||
#include "QsLog.h"
|
||||
#include <QDebug>
|
||||
#include <unistd.h>
|
||||
#include <QFile>
|
||||
|
||||
@ -30,7 +30,7 @@ bool OESystemComponent::componentInitialize()
|
||||
foreach(QString service, services.keys())
|
||||
{
|
||||
bool Enabled = SystemdManager::isEnabled(services[service]);
|
||||
QLOG_ERROR() << "Service " << services[service].Name << " enabled :" << Enabled;
|
||||
qCritical() << "Service " << services[service].Name << " enabled :" << Enabled;
|
||||
SettingsComponent::Get().setValue(SETTINGS_SECTION_SYSTEM,
|
||||
services[service].Name + "_enabled",
|
||||
Enabled);
|
||||
@ -62,7 +62,7 @@ bool OESystemComponent::setHostName(QString name)
|
||||
QFile file("/storage/.cache/hostname");
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
QLOG_ERROR() << "setHostName : Failed to open" << file.fileName();
|
||||
qCritical() << "setHostName : Failed to open" << file.fileName();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
|
||||
#include "QsLog.h"
|
||||
#include "SystemdManager.h"
|
||||
|
||||
#define CACHE_DIR "/storage/.cache/services/"
|
||||
@ -19,14 +19,14 @@ bool SystemdManager::enable(SystemdService &Service, bool enable)
|
||||
QFile offFile(CACHE_DIR + Service.ConfigFile + ".disabled");
|
||||
QFile templateFile(TEMPLATE_DIR + Service.ConfigFile + ".conf");
|
||||
|
||||
QLOG_INFO() << "Setting service" << Service.Name << "to enable state :" << enable;
|
||||
qInfo() << "Setting service" << Service.Name << "to enable state :" << enable;
|
||||
|
||||
if (!onFile.exists() && !offFile.exists())
|
||||
{
|
||||
// we take the template file and copy it over
|
||||
if(!templateFile.copy(enable ? onFile.fileName() : offFile.fileName()))
|
||||
{
|
||||
QLOG_ERROR() << "Failed to copy template file for service " << Service.Name;
|
||||
qCritical() << "Failed to copy template file for service " << Service.Name;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -53,7 +53,7 @@ bool SystemdManager::enable(SystemdService &Service, bool enable)
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_ERROR() << "Failed to restart service " << Service.Name;
|
||||
qCritical() << "Failed to restart service " << Service.Name;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ TaskbarComponent& TaskbarComponent::Get()
|
||||
static TaskbarComponentWin instance;
|
||||
return instance;
|
||||
#else
|
||||
QLOG_WARN() << "Could not find a taskbar component matching this platform. Taskbar functions disabled.";
|
||||
qWarning() << "Could not find a taskbar component matching this platform. Taskbar functions disabled.";
|
||||
|
||||
static TaskbarComponent instance;
|
||||
return instance;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef TASKBARCOMPONENT_H
|
||||
#define TASKBARCOMPONENT_H
|
||||
|
||||
#include <QsLog.h>
|
||||
#include <QDebug>
|
||||
#include <QQuickWindow>
|
||||
#include "ComponentManager.h"
|
||||
|
||||
|
@ -32,7 +32,7 @@ TaskbarComponentWin::~TaskbarComponentWin()
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
void TaskbarComponentWin::setWindow(QQuickWindow* window)
|
||||
{
|
||||
QLOG_DEBUG() << "Taskbar initialization started";
|
||||
qDebug() << "Taskbar initialization started";
|
||||
TaskbarComponent::setWindow(window);
|
||||
|
||||
m_button = new QWinTaskbarButton(m_window);
|
||||
@ -164,14 +164,14 @@ void TaskbarComponentWin::initializeMediaTransport(HWND hwnd)
|
||||
auto hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Media_SystemMediaTransportControls).Get(), &interop);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed instantiating interop object";
|
||||
qWarning() << "Failed instantiating interop object";
|
||||
return;
|
||||
}
|
||||
|
||||
hr = interop->GetForWindow(hwnd, IID_PPV_ARGS(&m_systemControls));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to GetForWindow";
|
||||
qWarning() << "Failed to GetForWindow";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ void TaskbarComponentWin::initializeMediaTransport(HWND hwnd)
|
||||
hr = m_systemControls->add_ButtonPressed(handler.Get(), &m_buttonPressedToken);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to add callback handler";
|
||||
qWarning() << "Failed to add callback handler";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -204,12 +204,12 @@ void TaskbarComponentWin::initializeMediaTransport(HWND hwnd)
|
||||
hr = m_systemControls->get_DisplayUpdater(&m_displayUpdater);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to get Display updater";
|
||||
qWarning() << "Failed to get Display updater";
|
||||
return;
|
||||
}
|
||||
|
||||
m_initialized = true;
|
||||
QLOG_INFO() << "SystemMediaTransportControls successfully initialized";
|
||||
qInfo() << "SystemMediaTransportControls successfully initialized";
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -224,7 +224,7 @@ void TaskbarComponentWin::onMetaData(const QVariantMap& meta, QUrl baseUrl)
|
||||
hr = m_displayUpdater->ClearAll();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to clear display metadata";
|
||||
qWarning() << "Failed to clear display metadata";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ void TaskbarComponentWin::onMetaData(const QVariantMap& meta, QUrl baseUrl)
|
||||
hr = m_displayUpdater->Update();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to update the display";
|
||||
qWarning() << "Failed to update the display";
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -255,7 +255,7 @@ void TaskbarComponentWin::setAudioMeta(const QVariantMap& meta)
|
||||
hr = m_displayUpdater->put_Type(MediaPlaybackType::MediaPlaybackType_Music);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to set the media type to music";
|
||||
qWarning() << "Failed to set the media type to music";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ void TaskbarComponentWin::setAudioMeta(const QVariantMap& meta)
|
||||
hr = m_displayUpdater->get_MusicProperties(musicProps.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to get music properties";
|
||||
qWarning() << "Failed to get music properties";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ void TaskbarComponentWin::setAudioMeta(const QVariantMap& meta)
|
||||
hr = musicProps->put_Artist(HStringReference((const wchar_t*)artist.utf16()).Get());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to set the music's artist";
|
||||
qWarning() << "Failed to set the music's artist";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ void TaskbarComponentWin::setAudioMeta(const QVariantMap& meta)
|
||||
hr = musicProps->put_Title(HStringReference((const wchar_t*)title.utf16()).Get());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to set the music's title";
|
||||
qWarning() << "Failed to set the music's title";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ void TaskbarComponentWin::setAudioMeta(const QVariantMap& meta)
|
||||
hr = musicProps->put_AlbumArtist(HStringReference((const wchar_t*)albumArtist.utf16()).Get());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to set the music's album artist";
|
||||
qWarning() << "Failed to set the music's album artist";
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -300,7 +300,7 @@ void TaskbarComponentWin::setVideoMeta(const QVariantMap& meta)
|
||||
hr = m_displayUpdater->put_Type(MediaPlaybackType::MediaPlaybackType_Video);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to set the media type to video";
|
||||
qWarning() << "Failed to set the media type to video";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ void TaskbarComponentWin::setVideoMeta(const QVariantMap& meta)
|
||||
hr = m_displayUpdater->get_VideoProperties(videoProps.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to get video properties";
|
||||
qWarning() << "Failed to get video properties";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ void TaskbarComponentWin::setVideoMeta(const QVariantMap& meta)
|
||||
hr = videoProps->put_Title(HStringReference((const wchar_t*)title.utf16()).Get());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to set the video title";
|
||||
qWarning() << "Failed to set the video title";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -326,7 +326,7 @@ void TaskbarComponentWin::setVideoMeta(const QVariantMap& meta)
|
||||
hr = videoProps->put_Subtitle(HStringReference((const wchar_t*)subtitle.utf16()).Get());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to set the video subtitle";
|
||||
qWarning() << "Failed to set the video subtitle";
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -363,7 +363,7 @@ void TaskbarComponentWin::setThumbnail(const QVariantMap& meta, QUrl baseUrl)
|
||||
}
|
||||
else
|
||||
{
|
||||
QLOG_DEBUG() << "No Primary image found. Do nothing";
|
||||
qDebug() << "No Primary image found. Do nothing";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -374,7 +374,7 @@ void TaskbarComponentWin::setThumbnail(const QVariantMap& meta, QUrl baseUrl)
|
||||
&streamRefFactory);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed instantiating stream factory";
|
||||
qWarning() << "Failed instantiating stream factory";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ void TaskbarComponentWin::setThumbnail(const QVariantMap& meta, QUrl baseUrl)
|
||||
hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_Uri).Get(), &uriFactory);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed instantiating uri factory";
|
||||
qWarning() << "Failed instantiating uri factory";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -390,21 +390,21 @@ void TaskbarComponentWin::setThumbnail(const QVariantMap& meta, QUrl baseUrl)
|
||||
hr = uriFactory->CreateUri(HStringReference((const wchar_t*)imgUrl.utf16()).Get(), &uri);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to create uri";
|
||||
qWarning() << "Failed to create uri";
|
||||
return;
|
||||
}
|
||||
|
||||
hr = streamRefFactory->CreateFromUri(uri.Get(), &m_thumbnail);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to create stream from uri";
|
||||
qWarning() << "Failed to create stream from uri";
|
||||
return;
|
||||
}
|
||||
|
||||
hr = m_displayUpdater->put_Thumbnail(m_thumbnail.Get());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to set thumbnail";
|
||||
qWarning() << "Failed to set thumbnail";
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -417,7 +417,7 @@ HRESULT TaskbarComponentWin::buttonPressed(ISystemMediaTransportControls* sender
|
||||
auto hr = args->get_Button(&button);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
QLOG_WARN() << "Failed to get the pressed button";
|
||||
qWarning() << "Failed to get the pressed button";
|
||||
return hr;
|
||||
}
|
||||
|
||||
@ -425,42 +425,42 @@ HRESULT TaskbarComponentWin::buttonPressed(ISystemMediaTransportControls* sender
|
||||
{
|
||||
case SystemMediaTransportControlsButton::SystemMediaTransportControlsButton_Play:
|
||||
InputComponent::Get().sendAction("play_pause");
|
||||
QLOG_DEBUG() << "Received play button press";
|
||||
qDebug() << "Received play button press";
|
||||
break;
|
||||
case SystemMediaTransportControlsButton::SystemMediaTransportControlsButton_Pause:
|
||||
InputComponent::Get().sendAction("play_pause");
|
||||
QLOG_DEBUG() << "Received pause button press";
|
||||
qDebug() << "Received pause button press";
|
||||
break;
|
||||
case SystemMediaTransportControlsButton::SystemMediaTransportControlsButton_Next:
|
||||
InputComponent::Get().sendAction("next");
|
||||
QLOG_DEBUG() << "Received next button press";
|
||||
qDebug() << "Received next button press";
|
||||
break;
|
||||
case SystemMediaTransportControlsButton::SystemMediaTransportControlsButton_Previous:
|
||||
InputComponent::Get().sendAction("previous");
|
||||
QLOG_DEBUG() << "Received previous button press";
|
||||
qDebug() << "Received previous button press";
|
||||
break;
|
||||
case SystemMediaTransportControlsButton::SystemMediaTransportControlsButton_Stop:
|
||||
InputComponent::Get().sendAction("stop");
|
||||
QLOG_DEBUG() << "Received stop button press";
|
||||
qDebug() << "Received stop button press";
|
||||
break;
|
||||
case SystemMediaTransportControlsButton::SystemMediaTransportControlsButton_FastForward:
|
||||
InputComponent::Get().sendAction("seek_forward");
|
||||
QLOG_DEBUG() << "Received seek_forward button press";
|
||||
qDebug() << "Received seek_forward button press";
|
||||
break;
|
||||
case SystemMediaTransportControlsButton::SystemMediaTransportControlsButton_Rewind:
|
||||
InputComponent::Get().sendAction("seek_backward");
|
||||
QLOG_DEBUG() << "Received seek_backward button press";
|
||||
qDebug() << "Received seek_backward button press";
|
||||
break;
|
||||
case SystemMediaTransportControlsButton::SystemMediaTransportControlsButton_ChannelUp:
|
||||
InputComponent::Get().sendAction("channelup");
|
||||
QLOG_DEBUG() << "Received channelup button press";
|
||||
qDebug() << "Received channelup button press";
|
||||
break;
|
||||
case SystemMediaTransportControlsButton::SystemMediaTransportControlsButton_ChannelDown:
|
||||
InputComponent::Get().sendAction("channeldown");
|
||||
QLOG_DEBUG() << "Received channeldown button press";
|
||||
qDebug() << "Received channeldown button press";
|
||||
break;
|
||||
case SystemMediaTransportControlsButton::SystemMediaTransportControlsButton_Record:
|
||||
QLOG_DEBUG() << "Received unsupported button press";
|
||||
qDebug() << "Received unsupported button press";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QDebug>
|
||||
|
||||
#include "core/Version.h"
|
||||
#include "input/InputKeyboard.h"
|
||||
@ -16,7 +17,6 @@
|
||||
#include "player/PlayerQuickItem.h"
|
||||
#include "display/DisplayComponent.h"
|
||||
#include "taskbar/TaskbarComponent.h"
|
||||
#include "QsLog.h"
|
||||
#include "utils/Utils.h"
|
||||
#include "Globals.h"
|
||||
#include "EventFilter.h"
|
||||
@ -166,7 +166,7 @@ bool KonvergoWindow::fitsInScreens(const QRect& rc)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void KonvergoWindow::saveGeometry()
|
||||
{
|
||||
QLOG_DEBUG() << "Window state when saving geometry:" << visibility();
|
||||
qDebug() << "Window state when saving geometry:" << visibility();
|
||||
|
||||
QRect rc = geometry();
|
||||
|
||||
@ -177,7 +177,7 @@ void KonvergoWindow::saveGeometry()
|
||||
if (!fitsInScreens(rc))
|
||||
return;
|
||||
|
||||
QLOG_DEBUG() << "Saving window geometry:" << rc;
|
||||
qDebug() << "Saving window geometry:" << rc;
|
||||
|
||||
if (visibility() == QWindow::Maximized)
|
||||
{
|
||||
@ -206,7 +206,7 @@ QRect KonvergoWindow::loadGeometry()
|
||||
|
||||
if (SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "fullscreen").toBool())
|
||||
{
|
||||
QLOG_DEBUG() << "Load FullScreen geo...";
|
||||
qDebug() << "Load FullScreen geo...";
|
||||
|
||||
if (myScreen)
|
||||
{
|
||||
@ -254,11 +254,11 @@ QRect KonvergoWindow::loadGeometryRect()
|
||||
|
||||
QRect rc(map["x"].toInt(), map["y"].toInt(), map["width"].toInt(), map["height"].toInt());
|
||||
|
||||
QLOG_DEBUG() << "Restoring geo:" << rc;
|
||||
qDebug() << "Restoring geo:" << rc;
|
||||
|
||||
if (!rc.isValid() || rc.isEmpty())
|
||||
{
|
||||
QLOG_DEBUG() << "Geo bad, going for defaults";
|
||||
qDebug() << "Geo bad, going for defaults";
|
||||
return defaultRect;
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ QRect KonvergoWindow::loadGeometryRect()
|
||||
// also make sure we are not putting windows outside the screen somewhere
|
||||
if (!fitsInScreens(rc))
|
||||
{
|
||||
QLOG_DEBUG() << "Could not fit stored geo into current screens";
|
||||
qDebug() << "Could not fit stored geo into current screens";
|
||||
return defaultRect;
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ void KonvergoWindow::enableVideoWindow()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void KonvergoWindow::setFullScreen(bool enable)
|
||||
{
|
||||
QLOG_DEBUG() << "setting fullscreen = " << enable;
|
||||
qDebug() << "setting fullscreen = " << enable;
|
||||
|
||||
SettingsComponent::Get().setValue(SETTINGS_SECTION_MAIN, "fullscreen", enable);
|
||||
}
|
||||
@ -308,7 +308,7 @@ void KonvergoWindow::toggleWebMode()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void KonvergoWindow::setAlwaysOnTop(bool enable)
|
||||
{
|
||||
QLOG_DEBUG() << "setting always on top = " << enable;
|
||||
qDebug() << "setting always on top = " << enable;
|
||||
|
||||
// Update the settings value.
|
||||
SettingsComponent::Get().setValue(SETTINGS_SECTION_MAIN, "alwaysOnTop", enable);
|
||||
@ -404,7 +404,7 @@ void KonvergoWindow::updateForcedScreen()
|
||||
{
|
||||
if (scr->name() == screenName)
|
||||
{
|
||||
QLOG_DEBUG() << "Forcing screen to" << scr->name();
|
||||
qDebug() << "Forcing screen to" << scr->name();
|
||||
setScreen(scr);
|
||||
setGeometry(scr->geometry());
|
||||
setVisibility(QWindow::FullScreen);
|
||||
@ -476,11 +476,11 @@ QScreen* KonvergoWindow::findCurrentScreen()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void KonvergoWindow::onVisibilityChanged(QWindow::Visibility visibility)
|
||||
{
|
||||
QLOG_DEBUG() << "QWindow visibility set to" << visibility;
|
||||
qDebug() << "QWindow visibility set to" << visibility;
|
||||
|
||||
if (visibility == QWindow::Windowed && SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "forceAlwaysFS").toBool())
|
||||
{
|
||||
QLOG_WARN() << "Forcing re-entering fullscreen because of forceAlwaysFS setting!";
|
||||
qWarning() << "Forcing re-entering fullscreen because of forceAlwaysFS setting!";
|
||||
updateForcedScreen(); // if a specific screen is forced, try to move the window there
|
||||
setVisibility(QWindow::FullScreen);
|
||||
return;
|
||||
@ -508,7 +508,7 @@ void KonvergoWindow::focusOutEvent(QFocusEvent * ev)
|
||||
// The compositor will not properly redraw anything when focusing other windows.
|
||||
if (visibility() == QWindow::FullScreen && SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "minimizeOnDefocus").toBool())
|
||||
{
|
||||
QLOG_DEBUG() << "minimizing window";
|
||||
qDebug() << "minimizing window";
|
||||
showMinimized();
|
||||
}
|
||||
#endif
|
||||
@ -579,7 +579,7 @@ void KonvergoWindow::toggleDebug()
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
void KonvergoWindow::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QLOG_DEBUG() << "resize event:" << event->size();
|
||||
qDebug() << "resize event:" << event->size();
|
||||
|
||||
// This next block was added at some point to workaround a problem with
|
||||
// resizing on windows. Unfortunately it broke the desktop client behavior
|
||||
@ -599,7 +599,7 @@ void KonvergoWindow::resizeEvent(QResizeEvent* event)
|
||||
QSize fsSize = screen()->size();
|
||||
if (event->size().width() < fsSize.width() || event->size().height() < fsSize.height())
|
||||
{
|
||||
QLOG_DEBUG() << "Ignoring resize event when in fullscreen...";
|
||||
qDebug() << "Ignoring resize event when in fullscreen...";
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -623,7 +623,7 @@ QScreen* KonvergoWindow::loadLastScreen()
|
||||
return scr;
|
||||
}
|
||||
|
||||
QLOG_DEBUG() << "Tried to find screen:" << screenName << "but it was not present";
|
||||
qDebug() << "Tried to find screen:" << screenName << "but it was not present";
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -668,7 +668,7 @@ void KonvergoWindow::updateScreens()
|
||||
if (selected)
|
||||
currentPresent = true;
|
||||
|
||||
QLOG_DEBUG() << "Screen" << (num++) << screen << screen->geometry()
|
||||
qDebug() << "Screen" << (num++) << screen << screen->geometry()
|
||||
<< screen->virtualGeometry() << "active:" << active
|
||||
<< "selected:" << selected;
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Created by Tobias Hieta on 20/08/15.
|
||||
//
|
||||
|
||||
#include <QDebug>
|
||||
#include "CachedRegexMatcher.h"
|
||||
#include "QsLog.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool CachedRegexMatcher::addMatcher(const QString& pattern, const QVariant& result)
|
||||
@ -11,7 +11,7 @@ bool CachedRegexMatcher::addMatcher(const QString& pattern, const QVariant& resu
|
||||
QRegExp matcher(pattern);
|
||||
if (!matcher.isValid())
|
||||
{
|
||||
QLOG_WARN() << "Could not compile pattern:" << pattern;
|
||||
qWarning() << "Could not compile pattern:" << pattern;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ QVariantList CachedRegexMatcher::match(const QString& input)
|
||||
}
|
||||
}
|
||||
|
||||
QLOG_DEBUG() << "No match for:" << input;
|
||||
qDebug() << "No match for:" << input;
|
||||
|
||||
if (!matches.isEmpty())
|
||||
{
|
||||
|
@ -6,41 +6,44 @@
|
||||
|
||||
#include <QtQml>
|
||||
#include <QGuiApplication>
|
||||
#include <iostream>
|
||||
|
||||
#include "QsLog.h"
|
||||
#include "shared/Names.h"
|
||||
#include "shared/Paths.h"
|
||||
#include "settings/SettingsComponent.h"
|
||||
#include "Version.h"
|
||||
|
||||
using namespace QsLogging;
|
||||
int logLevel = 0;
|
||||
bool logToTerminal = false;
|
||||
QHash<QtMsgType, int> messageLevelValue({{QtDebugMsg, 1}, {QtInfoMsg, 2}, {QtWarningMsg, 3}, {QtCriticalMsg, 4}, {QtFatalMsg, 5}});
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// adapted from https://stackoverflow.com/a/62390212
|
||||
static void qtMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
QString prefix;
|
||||
if (context.line)
|
||||
prefix = QString("%1:%2:%3: ").arg(context.file).arg(context.line).arg(context.function);
|
||||
QString text = prefix + msg;
|
||||
switch (type)
|
||||
{
|
||||
case QtDebugMsg:
|
||||
QLOG_DEBUG() << text;
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
QLOG_INFO() << text;
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
QLOG_WARN() << text;
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
QLOG_ERROR() << text;
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
QLOG_FATAL() << text;
|
||||
break;
|
||||
}
|
||||
static QMutex mutex;
|
||||
QMutexLocker lock(&mutex);
|
||||
|
||||
if (messageLevelValue[type] < logLevel && type != QtFatalMsg)
|
||||
return;
|
||||
|
||||
static QFile logFile(Paths::logDir(Names::MainName() + ".log"));
|
||||
static bool logFileIsOpen = logFile.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text);
|
||||
|
||||
QString message = qFormatLogMessage(type, context, msg);
|
||||
Log::CensorAuthTokens(message);
|
||||
|
||||
if (logToTerminal) {
|
||||
std::cerr << qPrintable(message) << std::endl;
|
||||
}
|
||||
|
||||
if (logFileIsOpen) {
|
||||
logFile.write(message.toUtf8() + '\n');
|
||||
logFile.flush();
|
||||
}
|
||||
|
||||
if (type == QtFatalMsg)
|
||||
abort();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -61,26 +64,25 @@ static void elidePattern(QString& msg, const QString& substring, int chars)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Log::CensorAuthTokens(QString& msg)
|
||||
{
|
||||
elidePattern(msg, "api_key=", 20);
|
||||
elidePattern(msg, "X-MediaBrowser-Token%3D", 20);
|
||||
elidePattern(msg, "X-MediaBrowser-Token=", 20);
|
||||
elidePattern(msg, "api_key=", 20);
|
||||
elidePattern(msg, "ApiKey=", 20);
|
||||
elidePattern(msg, "AccessToken=", 20);
|
||||
elidePattern(msg, "api_key=", 32);
|
||||
elidePattern(msg, "X-MediaBrowser-Token%3D", 32);
|
||||
elidePattern(msg, "X-MediaBrowser-Token=", 32);
|
||||
elidePattern(msg, "api_key=", 32);
|
||||
elidePattern(msg, "ApiKey=", 32);
|
||||
elidePattern(msg, "AccessToken=", 32);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
static QsLogging::Level logLevelFromString(const QString& str)
|
||||
static int logLevelFromString(const QString& str)
|
||||
{
|
||||
if (str == "trace") return QsLogging::Level::TraceLevel;
|
||||
if (str == "debug") return QsLogging::Level::DebugLevel;
|
||||
if (str == "info") return QsLogging::Level::InfoLevel;
|
||||
if (str == "warn") return QsLogging::Level::WarnLevel;
|
||||
if (str == "error") return QsLogging::Level::ErrorLevel;
|
||||
if (str == "fatal") return QsLogging::Level::FatalLevel;
|
||||
if (str == "disable") return QsLogging::Level::OffLevel;
|
||||
if (str == "trace") return 0;
|
||||
if (str == "debug") return 1;
|
||||
if (str == "info") return 2;
|
||||
if (str == "warn") return 3;
|
||||
if (str == "error") return 4;
|
||||
if (str == "fatal") return 5;
|
||||
// if not valid, use default
|
||||
return QsLogging::Level::DebugLevel;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -89,44 +91,39 @@ void Log::UpdateLogLevel()
|
||||
QString level = SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "logLevel").toString();
|
||||
if (level.size())
|
||||
{
|
||||
QLOG_INFO() << "Setting log level to:" << level;
|
||||
Logger::instance().setLoggingLevel(logLevelFromString(level));
|
||||
qInfo() << "Setting log level to:" << level;
|
||||
logLevel = logLevelFromString(level);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool Log::ShouldLogInfo()
|
||||
{
|
||||
return logLevel <= 2;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Log::Init()
|
||||
{
|
||||
// Note where the logfile is going to be
|
||||
qDebug("Logging to %s", qPrintable(Paths::logDir(Names::MainName() + ".log")));
|
||||
|
||||
// init logging.
|
||||
DestinationPtr dest = DestinationFactory::MakeFileDestination(
|
||||
Paths::logDir(Names::MainName() + ".log"),
|
||||
EnableLogRotationOnOpen,
|
||||
MaxSizeBytes(1024 * 1024),
|
||||
MaxOldLogCount(9));
|
||||
|
||||
Logger::instance().addDestination(dest);
|
||||
Logger::instance().setLoggingLevel(DebugLevel);
|
||||
Logger::instance().setProcessingCallback(Log::CensorAuthTokens);
|
||||
qDebug() << "Logging to " << qPrintable(Paths::logDir(Names::MainName() + ".log"));
|
||||
|
||||
qSetMessagePattern("%{time yyyy-MM-dd hh:mm:ss.zzz} [%{type}] %{function} @ %{line} - %{message}");
|
||||
qInstallMessageHandler(qtMessageOutput);
|
||||
|
||||
QLOG_INFO() << "Starting Jellyfin Media Player version:" << qPrintable(Version::GetVersionString()) << "build date:" << qPrintable(Version::GetBuildDate());
|
||||
QLOG_INFO() << qPrintable(QString(" Running on: %1 [%2] arch %3").arg(QSysInfo::prettyProductName()).arg(QSysInfo::kernelVersion()).arg(QSysInfo::currentCpuArchitecture()));
|
||||
QLOG_INFO() << " Qt Version:" << QT_VERSION_STR << qPrintable(QString("[%1]").arg(QSysInfo::buildAbi()));
|
||||
qInfo() << "Starting Jellyfin Media Player version:" << qPrintable(Version::GetVersionString()) << "build date:" << qPrintable(Version::GetBuildDate());
|
||||
qInfo() << qPrintable(QString(" Running on: %1 [%2] arch %3").arg(QSysInfo::prettyProductName()).arg(QSysInfo::kernelVersion()).arg(QSysInfo::currentCpuArchitecture()));
|
||||
qInfo() << " Qt Version:" << QT_VERSION_STR << qPrintable(QString("[%1]").arg(QSysInfo::buildAbi()));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Log::EnableTerminalOutput()
|
||||
{
|
||||
Logger::instance().addDestination(DestinationFactory::MakeDebugOutputDestination());
|
||||
logToTerminal = true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Log::Uninit()
|
||||
{
|
||||
qInstallMessageHandler(0);
|
||||
Logger::destroyInstance();
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace Log
|
||||
void UpdateLogLevel();
|
||||
void CensorAuthTokens(QString& msg);
|
||||
void EnableTerminalOutput();
|
||||
bool ShouldLogInfo();
|
||||
}
|
||||
|
||||
#endif //PLEXMEDIAPLAYER_LOG_H
|
||||
|
@ -12,14 +12,13 @@
|
||||
#include <QUuid>
|
||||
#include <QFile>
|
||||
#include <QSaveFile>
|
||||
#include <QDebug>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "settings/SettingsComponent.h"
|
||||
#include "settings/SettingsSection.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
QList<QChar> httpSeparators = { '(', ')', '<', '>', '@', ',', ';', ':', '\\', '\"', '/', '[', ']', '?', '=', '{', '}', '\'' };
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "OSXUtils.h"
|
||||
#include "QsLog.h"
|
||||
#include <QDebug>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user