mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Logging enhancement / fixes (#1419)
* Instance in logging output * Fix: Trigger that previous log lines are shown in the Log UI
This commit is contained in:
parent
98654e48f6
commit
2efc03b612
@ -121,8 +121,8 @@ $(document).ready(function () {
|
||||
if (messages.length != 0) {
|
||||
|
||||
for (var idx = 0; idx < messages.length; idx++) {
|
||||
var app_name = messages[idx].appName;
|
||||
var logger_name = messages[idx].loggerName;
|
||||
var logger_subname = messages[idx].loggerSubName;
|
||||
var function_ = messages[idx].function;
|
||||
var line = messages[idx].line;
|
||||
var file_name = messages[idx].fileName;
|
||||
@ -136,7 +136,18 @@ $(document).ready(function () {
|
||||
}
|
||||
|
||||
var date = new Date(parseInt(utime));
|
||||
var newLogLine = date.toISOString() + " [" + app_name + " " + logger_name + "] (" + level_string + ") " + debug + msg;
|
||||
var subComponent = "";
|
||||
if (window.serverInfo.instance.length > 1) {
|
||||
if (logger_subname.startsWith("I")) {
|
||||
var instanceNum = logger_subname.substring(1);
|
||||
if (window.serverInfo.instance[instanceNum]) {
|
||||
subComponent = window.serverInfo.instance[instanceNum].friendly_name;
|
||||
} else {
|
||||
subComponent = instanceNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
var newLogLine = date.toISOString() + " [" + logger_name + (subComponent ? "|" + subComponent : "") + "] (" + level_string + ") " + debug + msg;
|
||||
|
||||
$("#logmessages").append("<code>" + newLogLine + "</code>\n");
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ public slots:
|
||||
/// @brief Get a pointer to the priorityMuxer instance
|
||||
/// @return PriorityMuxer instance pointer
|
||||
///
|
||||
PriorityMuxer* getMuxerInstance() { return &_muxer; }
|
||||
PriorityMuxer* getMuxerInstance() { return _muxer; }
|
||||
|
||||
///
|
||||
/// @brief enable/disable automatic/priorized source selection
|
||||
@ -340,7 +340,7 @@ public slots:
|
||||
/// @brief Get the component Register
|
||||
/// return Component register pointer
|
||||
///
|
||||
ComponentRegister & getComponentRegister() { return _componentRegister; }
|
||||
ComponentRegister* getComponentRegister() { return _componentRegister; }
|
||||
|
||||
///
|
||||
/// @brief Called from components to update their current state. DO NOT CALL FROM USERS
|
||||
@ -511,7 +511,7 @@ private:
|
||||
SettingsManager* _settingsManager;
|
||||
|
||||
/// Register that holds component states
|
||||
ComponentRegister _componentRegister;
|
||||
ComponentRegister* _componentRegister;
|
||||
|
||||
/// The specifiation of the led frame construction and picture integration
|
||||
LedString _ledString;
|
||||
@ -522,7 +522,7 @@ private:
|
||||
std::vector<ColorOrder> _ledStringColorOrder;
|
||||
|
||||
/// The priority muxer
|
||||
PriorityMuxer _muxer;
|
||||
PriorityMuxer* _muxer;
|
||||
|
||||
/// The adjustment from raw colors to led colors
|
||||
MultiColorAdjustment * _raw2ledAdjustment;
|
||||
|
@ -152,6 +152,13 @@ public:
|
||||
///
|
||||
static void printLedValues(const std::vector<ColorRgb>& ledValues);
|
||||
|
||||
///
|
||||
/// @brief Set the common logger for LED-devices.
|
||||
///
|
||||
/// @param[in] log The logger to be used
|
||||
///
|
||||
void setLogger(Logger* log) { _log = log; }
|
||||
|
||||
public slots:
|
||||
|
||||
///
|
||||
|
@ -54,8 +54,8 @@ public:
|
||||
|
||||
struct T_LOG_MESSAGE
|
||||
{
|
||||
QString appName;
|
||||
QString loggerName;
|
||||
QString loggerSubName;
|
||||
QString function;
|
||||
unsigned int line;
|
||||
QString fileName;
|
||||
@ -65,22 +65,22 @@ public:
|
||||
QString levelString;
|
||||
};
|
||||
|
||||
static Logger* getInstance(const QString & name = "", LogLevel minLevel=Logger::INFO);
|
||||
static void deleteInstance(const QString & name = "");
|
||||
static void setLogLevel(LogLevel level, const QString & name = "");
|
||||
static LogLevel getLogLevel(const QString & name = "");
|
||||
static Logger* getInstance(const QString & name = "", const QString & subName = "__", LogLevel minLevel=Logger::INFO);
|
||||
static void deleteInstance(const QString & name = "", const QString & subName = "__");
|
||||
static void setLogLevel(LogLevel level, const QString & name = "", const QString & subName = "__");
|
||||
static LogLevel getLogLevel(const QString & name = "", const QString & subName = "__");
|
||||
|
||||
void Message(LogLevel level, const char* sourceFile, const char* func, unsigned int line, const char* fmt, ...);
|
||||
void setMinLevel(LogLevel level) { _minLevel = static_cast<int>(level); }
|
||||
LogLevel getMinLevel() const { return static_cast<LogLevel>(int(_minLevel)); }
|
||||
QString getName() const { return _name; }
|
||||
QString getAppName() const { return _appname; }
|
||||
QString getSubName() const { return _subname; }
|
||||
|
||||
signals:
|
||||
void newLogMessage(Logger::T_LOG_MESSAGE);
|
||||
|
||||
protected:
|
||||
Logger(const QString & name="", LogLevel minLevel = INFO);
|
||||
Logger(const QString & name="", const QString & subName = "__", LogLevel minLevel = INFO);
|
||||
~Logger() override;
|
||||
|
||||
private:
|
||||
@ -95,12 +95,12 @@ private:
|
||||
static QAtomicInteger<int> GLOBAL_MIN_LOG_LEVEL;
|
||||
|
||||
const QString _name;
|
||||
const QString _appname;
|
||||
const QString _subname;
|
||||
const bool _syslogEnabled;
|
||||
const unsigned _loggerId;
|
||||
|
||||
/* Only non-const member, hence the atomic */
|
||||
QAtomicInteger<int> _minLevel;
|
||||
QAtomicInteger<int> _minLevel;
|
||||
};
|
||||
|
||||
class LoggerManager : public QObject
|
||||
|
@ -44,12 +44,12 @@ namespace hyperion {
|
||||
}
|
||||
};
|
||||
hyperion->setColor(PriorityMuxer::FG_PRIORITY, fg_color, fg_duration_ms);
|
||||
Info(Logger::getInstance("HYPERION"),"Initial foreground color set (%d %d %d)",fg_color.at(0).red,fg_color.at(0).green,fg_color.at(0).blue);
|
||||
Info(Logger::getInstance("HYPERION","I"+QString::number(hyperion->getInstanceIndex())),"Initial foreground color set (%d %d %d)",fg_color.at(0).red,fg_color.at(0).green,fg_color.at(0).blue);
|
||||
}
|
||||
else
|
||||
{
|
||||
int result = hyperion->setEffect(fgEffectConfig, PriorityMuxer::FG_PRIORITY, fg_duration_ms);
|
||||
Info(Logger::getInstance("HYPERION"),"Initial foreground effect '%s' %s", QSTRING_CSTR(fgEffectConfig), ((result == 0) ? "started" : "failed"));
|
||||
Info(Logger::getInstance("HYPERION","I"+QString::number(hyperion->getInstanceIndex())),"Initial foreground effect '%s' %s", QSTRING_CSTR(fgEffectConfig), ((result == 0) ? "started" : "failed"));
|
||||
}
|
||||
}
|
||||
#undef FGCONFIG_ARRAY
|
||||
|
@ -72,6 +72,8 @@ API::API(Logger *log, bool localConnection, QObject *parent)
|
||||
|
||||
void API::init()
|
||||
{
|
||||
assert(_hyperion);
|
||||
|
||||
bool apiAuthRequired = _authManager->isAuthRequired();
|
||||
|
||||
// For security we block external connections if default PW is set
|
||||
|
@ -617,7 +617,7 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const QString
|
||||
|
||||
// get available components
|
||||
QJsonArray component;
|
||||
std::map<hyperion::Components, bool> components = _hyperion->getComponentRegister().getRegister();
|
||||
std::map<hyperion::Components, bool> components = _hyperion->getComponentRegister()->getRegister();
|
||||
for (auto comp : components)
|
||||
{
|
||||
QJsonObject item;
|
||||
@ -1154,7 +1154,9 @@ void JsonAPI::handleLoggingCommand(const QJsonObject &message, const QString &co
|
||||
{
|
||||
_streaming_logging_reply["command"] = command + "-update";
|
||||
connect(LoggerManager::getInstance(), &LoggerManager::newLogMessage, this, &JsonAPI::incommingLogMessage);
|
||||
Debug(_log, "log streaming activated for client %s", _peerAddress.toStdString().c_str()); // needed to trigger log sending
|
||||
|
||||
emit incommingLogMessage (Logger::T_LOG_MESSAGE{}); // needed to trigger log sending
|
||||
Debug(_log, "log streaming activated for client %s", _peerAddress.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
else if (subcommand == "stop")
|
||||
@ -1783,22 +1785,26 @@ void JsonAPI::incommingLogMessage(const Logger::T_LOG_MESSAGE &msg)
|
||||
const QList<Logger::T_LOG_MESSAGE> *logBuffer = LoggerManager::getInstance()->getLogMessageBuffer();
|
||||
for (int i = 0; i < logBuffer->length(); i++)
|
||||
{
|
||||
message["appName"] = logBuffer->at(i).appName;
|
||||
message["loggerName"] = logBuffer->at(i).loggerName;
|
||||
message["function"] = logBuffer->at(i).function;
|
||||
message["line"] = QString::number(logBuffer->at(i).line);
|
||||
message["fileName"] = logBuffer->at(i).fileName;
|
||||
message["message"] = logBuffer->at(i).message;
|
||||
message["levelString"] = logBuffer->at(i).levelString;
|
||||
message["utime"] = QString::number(logBuffer->at(i).utime);
|
||||
//Only present records of the current log-level
|
||||
if ( logBuffer->at(i).level >= _log->getLogLevel())
|
||||
{
|
||||
message["loggerName"] = logBuffer->at(i).loggerName;
|
||||
message["loggerSubName"] = logBuffer->at(i).loggerSubName;
|
||||
message["function"] = logBuffer->at(i).function;
|
||||
message["line"] = QString::number(logBuffer->at(i).line);
|
||||
message["fileName"] = logBuffer->at(i).fileName;
|
||||
message["message"] = logBuffer->at(i).message;
|
||||
message["levelString"] = logBuffer->at(i).levelString;
|
||||
message["utime"] = QString::number(logBuffer->at(i).utime);
|
||||
|
||||
messageArray.append(message);
|
||||
messageArray.append(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message["appName"] = msg.appName;
|
||||
message["loggerName"] = msg.loggerName;
|
||||
message["loggerSubName"] = msg.loggerSubName;
|
||||
message["function"] = msg.function;
|
||||
message["line"] = QString::number(msg.line);
|
||||
message["fileName"] = msg.fileName;
|
||||
|
@ -156,6 +156,7 @@ void JsonCB::resetSubscriptions()
|
||||
|
||||
void JsonCB::setSubscriptionsTo(Hyperion* hyperion)
|
||||
{
|
||||
assert(hyperion);
|
||||
//std::cout << "JsonCB::setSubscriptions for instance [" << static_cast<int>(hyperion->getInstanceIndex()) << "] " << std::endl;
|
||||
|
||||
// get current subs
|
||||
@ -166,7 +167,7 @@ void JsonCB::setSubscriptionsTo(Hyperion* hyperion)
|
||||
|
||||
// update pointer
|
||||
_hyperion = hyperion;
|
||||
_componentRegister = &_hyperion->getComponentRegister();
|
||||
_componentRegister = _hyperion->getComponentRegister();
|
||||
_prioMuxer = _hyperion->getMuxerInstance();
|
||||
|
||||
// re-apply subs
|
||||
|
@ -69,7 +69,7 @@ void BlackBorderProcessor::handleSettingsUpdate(settings::type type, const QJson
|
||||
_detector = new BlackBorderDetector(newThreshold);
|
||||
}
|
||||
|
||||
Debug(Logger::getInstance("BLACKBORDER"), "Set mode to: %s", QSTRING_CSTR(_detectionMode));
|
||||
Debug(Logger::getInstance("BLACKBORDER", "I"+QString::number(_hyperion->getInstanceIndex())), "Set mode to: %s", QSTRING_CSTR(_detectionMode));
|
||||
|
||||
// eval the comp state
|
||||
handleCompStateChangeRequest(hyperion::COMP_BLACKBORDER, obj["enable"].toBool(true));
|
||||
|
@ -19,9 +19,12 @@
|
||||
|
||||
EffectEngine::EffectEngine(Hyperion * hyperion)
|
||||
: _hyperion(hyperion)
|
||||
, _log(Logger::getInstance("EFFECTENGINE"))
|
||||
, _log(nullptr)
|
||||
, _effectFileHandler(EffectFileHandler::getInstance())
|
||||
{
|
||||
QString subComponent = hyperion->property("instance").toString();
|
||||
_log= Logger::getInstance("EFFECTENGINE", subComponent);
|
||||
|
||||
Q_INIT_RESOURCE(EffectEngine);
|
||||
qRegisterMetaType<hyperion::Components>("hyperion::Components");
|
||||
|
||||
|
@ -21,11 +21,14 @@
|
||||
|
||||
MessageForwarder::MessageForwarder(Hyperion* hyperion)
|
||||
: _hyperion(hyperion)
|
||||
, _log(Logger::getInstance("NETFORWARDER"))
|
||||
, _log(nullptr)
|
||||
, _muxer(_hyperion->getMuxerInstance())
|
||||
, _forwarder_enabled(true)
|
||||
, _priority(140)
|
||||
{
|
||||
QString subComponent = hyperion->property("instance").toString();
|
||||
_log= Logger::getInstance("NETFORWARDER", subComponent);
|
||||
|
||||
// get settings updates
|
||||
connect(_hyperion, &Hyperion::settingsChanged, this, &MessageForwarder::handleSettingsUpdate);
|
||||
|
||||
|
@ -9,8 +9,11 @@ using namespace hyperion;
|
||||
|
||||
ComponentRegister::ComponentRegister(Hyperion* hyperion)
|
||||
: _hyperion(hyperion)
|
||||
, _log(Logger::getInstance("COMPONENTREG"))
|
||||
, _log(nullptr)
|
||||
{
|
||||
QString subComponent = hyperion->property("instance").toString();
|
||||
_log= Logger::getInstance("COMPONENTREG", subComponent);
|
||||
|
||||
// init all comps to false
|
||||
QVector<hyperion::Components> vect;
|
||||
vect << COMP_ALL << COMP_SMOOTHING << COMP_LEDDEVICE;
|
||||
|
@ -49,10 +49,10 @@ Hyperion::Hyperion(quint8 instance, bool readonlyMode)
|
||||
: QObject()
|
||||
, _instIndex(instance)
|
||||
, _settingsManager(new SettingsManager(instance, this, readonlyMode))
|
||||
, _componentRegister(this)
|
||||
, _componentRegister(nullptr)
|
||||
, _ledString(hyperion::createLedString(getSetting(settings::LEDS).array(), hyperion::createColorOrder(getSetting(settings::DEVICE).object())))
|
||||
, _imageProcessor(new ImageProcessor(_ledString, this))
|
||||
, _muxer(static_cast<int>(_ledString.leds().size()), this)
|
||||
, _imageProcessor(nullptr)
|
||||
, _muxer(nullptr)
|
||||
, _raw2ledAdjustment(hyperion::createLedColorsAdjustment(static_cast<int>(_ledString.leds().size()), getSetting(settings::COLOR).object()))
|
||||
, _ledDeviceWrapper(nullptr)
|
||||
, _deviceSmooth(nullptr)
|
||||
@ -60,7 +60,7 @@ Hyperion::Hyperion(quint8 instance, bool readonlyMode)
|
||||
#if defined(ENABLE_FORWARDER)
|
||||
, _messageForwarder(nullptr)
|
||||
#endif
|
||||
, _log(Logger::getInstance("HYPERION"))
|
||||
, _log(nullptr)
|
||||
, _hwLedCount()
|
||||
, _ledGridSize(hyperion::getLedLayoutGridSize(getSetting(settings::LEDS).array()))
|
||||
, _BGEffectHandler(nullptr)
|
||||
@ -71,7 +71,14 @@ Hyperion::Hyperion(quint8 instance, bool readonlyMode)
|
||||
#endif
|
||||
, _readOnlyMode(readonlyMode)
|
||||
{
|
||||
QString subComponent = "I"+QString::number(instance);
|
||||
this->setProperty("instance", (QString) subComponent);
|
||||
|
||||
_log= Logger::getInstance("HYPERION", subComponent);
|
||||
|
||||
_componentRegister = new ComponentRegister(this);
|
||||
_imageProcessor = new ImageProcessor(_ledString, this);
|
||||
_muxer = new PriorityMuxer(static_cast<int>(_ledString.leds().size()), this);
|
||||
}
|
||||
|
||||
Hyperion::~Hyperion()
|
||||
@ -102,9 +109,9 @@ void Hyperion::start()
|
||||
}
|
||||
|
||||
// connect Hyperion::update with Muxer visible priority changes as muxer updates independent
|
||||
connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::update);
|
||||
connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::handleSourceAvailability);
|
||||
connect(&_muxer, &PriorityMuxer::visibleComponentChanged, this, &Hyperion::handleVisibleComponentChanged);
|
||||
connect(_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::update);
|
||||
connect(_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::handleSourceAvailability);
|
||||
connect(_muxer, &PriorityMuxer::visibleComponentChanged, this, &Hyperion::handleVisibleComponentChanged);
|
||||
|
||||
// listens for ComponentRegister changes of COMP_ALL to perform core enable/disable actions
|
||||
// connect(&_componentRegister, &ComponentRegister::updatedComponentState, this, &Hyperion::updatedComponentState);
|
||||
@ -199,6 +206,10 @@ void Hyperion::freeObjects()
|
||||
|
||||
delete _settingsManager;
|
||||
delete _ledDeviceWrapper;
|
||||
|
||||
delete _imageProcessor;
|
||||
delete _muxer;
|
||||
delete _componentRegister;
|
||||
}
|
||||
|
||||
void Hyperion::handleSettingsUpdate(settings::type type, const QJsonDocument& config)
|
||||
@ -228,7 +239,7 @@ void Hyperion::handleSettingsUpdate(settings::type type, const QJsonDocument& co
|
||||
// ledstring, img processor, muxer, ledGridSize (effect-engine image based effects), _ledBuffer and ByteOrder of ledstring
|
||||
_ledString = hyperion::createLedString(leds, hyperion::createColorOrder(getSetting(settings::DEVICE).object()));
|
||||
_imageProcessor->setLedString(_ledString);
|
||||
_muxer.updateLedColorsLength(static_cast<int>(_ledString.leds().size()));
|
||||
_muxer->updateLedColorsLength(static_cast<int>(_ledString.leds().size()));
|
||||
_ledGridSize = hyperion::getLedLayoutGridSize(leds);
|
||||
|
||||
std::vector<ColorRgb> color(_ledString.leds().size(), ColorRgb{0,0,0});
|
||||
@ -322,42 +333,42 @@ int Hyperion::getLedCount() const
|
||||
|
||||
void Hyperion::setSourceAutoSelect(bool state)
|
||||
{
|
||||
_muxer.setSourceAutoSelectEnabled(state);
|
||||
_muxer->setSourceAutoSelectEnabled(state);
|
||||
}
|
||||
|
||||
bool Hyperion::setVisiblePriority(int priority)
|
||||
{
|
||||
return _muxer.setPriority(priority);
|
||||
return _muxer->setPriority(priority);
|
||||
}
|
||||
|
||||
bool Hyperion::sourceAutoSelectEnabled() const
|
||||
{
|
||||
return _muxer.isSourceAutoSelectEnabled();
|
||||
return _muxer->isSourceAutoSelectEnabled();
|
||||
}
|
||||
|
||||
void Hyperion::setNewComponentState(hyperion::Components component, bool state)
|
||||
{
|
||||
_componentRegister.setNewComponentState(component, state);
|
||||
_componentRegister->setNewComponentState(component, state);
|
||||
}
|
||||
|
||||
std::map<hyperion::Components, bool> Hyperion::getAllComponents() const
|
||||
{
|
||||
return _componentRegister.getRegister();
|
||||
return _componentRegister->getRegister();
|
||||
}
|
||||
|
||||
int Hyperion::isComponentEnabled(hyperion::Components comp) const
|
||||
{
|
||||
return _componentRegister.isComponentEnabled(comp);
|
||||
return _componentRegister->isComponentEnabled(comp);
|
||||
}
|
||||
|
||||
void Hyperion::registerInput(int priority, hyperion::Components component, const QString& origin, const QString& owner, unsigned smooth_cfg)
|
||||
{
|
||||
_muxer.registerInput(priority, component, origin, owner, smooth_cfg);
|
||||
_muxer->registerInput(priority, component, origin, owner, smooth_cfg);
|
||||
}
|
||||
|
||||
bool Hyperion::setInput(int priority, const std::vector<ColorRgb>& ledColors, int timeout_ms, bool clearEffect)
|
||||
{
|
||||
if(_muxer.setInput(priority, ledColors, timeout_ms))
|
||||
if(_muxer->setInput(priority, ledColors, timeout_ms))
|
||||
{
|
||||
// clear effect if this call does not come from an effect
|
||||
if(clearEffect)
|
||||
@ -366,7 +377,7 @@ bool Hyperion::setInput(int priority, const std::vector<ColorRgb>& ledColors, in
|
||||
}
|
||||
|
||||
// if this priority is visible, update immediately
|
||||
if(priority == _muxer.getCurrentPriority())
|
||||
if(priority == _muxer->getCurrentPriority())
|
||||
{
|
||||
update();
|
||||
}
|
||||
@ -378,13 +389,13 @@ bool Hyperion::setInput(int priority, const std::vector<ColorRgb>& ledColors, in
|
||||
|
||||
bool Hyperion::setInputImage(int priority, const Image<ColorRgb>& image, int64_t timeout_ms, bool clearEffect)
|
||||
{
|
||||
if (!_muxer.hasPriority(priority))
|
||||
if (!_muxer->hasPriority(priority))
|
||||
{
|
||||
emit GlobalSignals::getInstance()->globalRegRequired(priority);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_muxer.setInputImage(priority, image, timeout_ms))
|
||||
if(_muxer->setInputImage(priority, image, timeout_ms))
|
||||
{
|
||||
// clear effect if this call does not come from an effect
|
||||
if(clearEffect)
|
||||
@ -393,7 +404,7 @@ bool Hyperion::setInputImage(int priority, const Image<ColorRgb>& image, int64_t
|
||||
}
|
||||
|
||||
// if this priority is visible, update immediately
|
||||
if(priority == _muxer.getCurrentPriority())
|
||||
if(priority == _muxer->getCurrentPriority())
|
||||
{
|
||||
update();
|
||||
}
|
||||
@ -405,7 +416,7 @@ bool Hyperion::setInputImage(int priority, const Image<ColorRgb>& image, int64_t
|
||||
|
||||
bool Hyperion::setInputInactive(quint8 priority)
|
||||
{
|
||||
return _muxer.setInputInactive(priority);
|
||||
return _muxer->setInputInactive(priority);
|
||||
}
|
||||
|
||||
void Hyperion::setColor(int priority, const std::vector<ColorRgb> &ledColors, int timeout_ms, const QString &origin, bool clearEffects)
|
||||
@ -465,7 +476,7 @@ bool Hyperion::clear(int priority, bool forceClearAll)
|
||||
bool isCleared = false;
|
||||
if (priority < 0)
|
||||
{
|
||||
_muxer.clearAll(forceClearAll);
|
||||
_muxer->clearAll(forceClearAll);
|
||||
|
||||
// send clearall signal to the effect engine
|
||||
_effectEngine->allChannelsCleared();
|
||||
@ -477,7 +488,7 @@ bool Hyperion::clear(int priority, bool forceClearAll)
|
||||
// (outside the check so the effect gets cleared even when the effect is not sending colors)
|
||||
_effectEngine->channelCleared(priority);
|
||||
|
||||
if (_muxer.clearInput(priority))
|
||||
if (_muxer->clearInput(priority))
|
||||
{
|
||||
isCleared = true;
|
||||
}
|
||||
@ -487,7 +498,7 @@ bool Hyperion::clear(int priority, bool forceClearAll)
|
||||
|
||||
int Hyperion::getCurrentPriority() const
|
||||
{
|
||||
return _muxer.getCurrentPriority();
|
||||
return _muxer->getCurrentPriority();
|
||||
}
|
||||
|
||||
bool Hyperion::isCurrentPriority(int priority) const
|
||||
@ -497,12 +508,12 @@ bool Hyperion::isCurrentPriority(int priority) const
|
||||
|
||||
QList<int> Hyperion::getActivePriorities() const
|
||||
{
|
||||
return _muxer.getPriorities();
|
||||
return _muxer->getPriorities();
|
||||
}
|
||||
|
||||
Hyperion::InputInfo Hyperion::getPriorityInfo(int priority) const
|
||||
{
|
||||
return _muxer.getInputInfo(priority);
|
||||
return _muxer->getInputInfo(priority);
|
||||
}
|
||||
|
||||
QString Hyperion::saveEffect(const QJsonObject& obj)
|
||||
@ -582,7 +593,7 @@ void Hyperion::handleVisibleComponentChanged(hyperion::Components comp)
|
||||
}
|
||||
|
||||
void Hyperion::handleSourceAvailability(const quint8& priority)
|
||||
{ int previousPriority = _muxer.getPreviousPriority();
|
||||
{ int previousPriority = _muxer->getPreviousPriority();
|
||||
|
||||
Debug(_log,"priority[%d], previousPriority[%d]", priority, previousPriority);
|
||||
if ( priority == PriorityMuxer::LOWEST_PRIORITY)
|
||||
@ -605,8 +616,8 @@ void Hyperion::handleSourceAvailability(const quint8& priority)
|
||||
void Hyperion::update()
|
||||
{
|
||||
// Obtain the current priority channel
|
||||
int priority = _muxer.getCurrentPriority();
|
||||
const PriorityMuxer::InputInfo priorityInfo = _muxer.getInputInfo(priority);
|
||||
int priority = _muxer->getCurrentPriority();
|
||||
const PriorityMuxer::InputInfo priorityInfo = _muxer->getInputInfo(priority);
|
||||
|
||||
// copy image & process OR copy ledColors from muxer
|
||||
Image<ColorRgb> image = priorityInfo.image;
|
||||
|
@ -11,7 +11,7 @@ HyperionIManager* HyperionIManager::HIMinstance;
|
||||
|
||||
HyperionIManager::HyperionIManager(const QString& rootPath, QObject* parent, bool readonlyMode)
|
||||
: QObject(parent)
|
||||
, _log(Logger::getInstance("HYPERION"))
|
||||
, _log(Logger::getInstance("HYPERION-INSTMGR"))
|
||||
, _instanceTable( new InstanceTable(rootPath, this, readonlyMode) )
|
||||
, _rootPath( rootPath )
|
||||
, _readonlyMode(readonlyMode)
|
||||
|
@ -28,7 +28,7 @@ QString ImageProcessor::mappingTypeToStr(int mappingType)
|
||||
|
||||
ImageProcessor::ImageProcessor(const LedString& ledString, Hyperion* hyperion)
|
||||
: QObject(hyperion)
|
||||
, _log(Logger::getInstance("IMAGETOLED"))
|
||||
, _log(nullptr)
|
||||
, _ledString(ledString)
|
||||
, _borderProcessor(new BlackBorderProcessor(hyperion, this))
|
||||
, _imageToLeds(nullptr)
|
||||
@ -37,6 +37,9 @@ ImageProcessor::ImageProcessor(const LedString& ledString, Hyperion* hyperion)
|
||||
, _hardMappingType(0)
|
||||
, _hyperion(hyperion)
|
||||
{
|
||||
QString subComponent = hyperion->property("instance").toString();
|
||||
_log= Logger::getInstance("IMAGETOLED", subComponent);
|
||||
|
||||
// init
|
||||
handleSettingsUpdate(settings::COLOR, _hyperion->getSetting(settings::COLOR));
|
||||
// listen for changes in color - ledmapping
|
||||
|
@ -50,7 +50,7 @@ const unsigned DEFAUL_OUTPUTDEPLAY = 0; // outputdelay in ms
|
||||
|
||||
LinearColorSmoothing::LinearColorSmoothing(const QJsonDocument &config, Hyperion *hyperion)
|
||||
: QObject(hyperion)
|
||||
, _log(Logger::getInstance("SMOOTHING"))
|
||||
, _log(nullptr)
|
||||
, _hyperion(hyperion)
|
||||
, _updateInterval(DEFAUL_UPDATEINTERVALL.count())
|
||||
, _settlingTime(DEFAUL_SETTLINGTIME)
|
||||
@ -62,6 +62,9 @@ LinearColorSmoothing::LinearColorSmoothing(const QJsonDocument &config, Hyperion
|
||||
, _enabled(false)
|
||||
, tempValues(std::vector<uint64_t>(0, 0L))
|
||||
{
|
||||
QString subComponent = hyperion->property("instance").toString();
|
||||
_log= Logger::getInstance("SMOOTHING", subComponent);
|
||||
|
||||
// init cfg 0 (default)
|
||||
addConfig(DEFAUL_SETTLINGTIME, DEFAUL_UPDATEFREQUENCY, DEFAUL_OUTPUTDEPLAY);
|
||||
handleSettingsUpdate(settings::SMOOTHING, config);
|
||||
|
@ -20,7 +20,7 @@ const int PriorityMuxer::TIMEOUT_NOT_ACTIVE_PRIO = -100;
|
||||
|
||||
PriorityMuxer::PriorityMuxer(int ledCount, QObject * parent)
|
||||
: QObject(parent)
|
||||
, _log(Logger::getInstance("HYPERION"))
|
||||
, _log(nullptr)
|
||||
, _currentPriority(PriorityMuxer::LOWEST_PRIORITY)
|
||||
, _previousPriority(_currentPriority)
|
||||
, _manualSelectedPriority(MANUAL_SELECTED_PRIORITY)
|
||||
@ -32,6 +32,9 @@ PriorityMuxer::PriorityMuxer(int ledCount, QObject * parent)
|
||||
, _timer(new QTimer(this))
|
||||
, _blockTimer(new QTimer(this))
|
||||
{
|
||||
QString subComponent = parent->property("instance").toString();
|
||||
_log= Logger::getInstance("MUXER", subComponent);
|
||||
|
||||
// init lowest priority info
|
||||
_lowestPriorityInfo.priority = PriorityMuxer::LOWEST_PRIORITY;
|
||||
_lowestPriorityInfo.timeoutTime_ms = -1;
|
||||
|
@ -28,7 +28,7 @@ QJsonObject SettingsManager::schemaJson;
|
||||
|
||||
SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonlyMode)
|
||||
: QObject(parent)
|
||||
, _log(Logger::getInstance("SETTINGSMGR"))
|
||||
, _log(Logger::getInstance("SETTINGSMGR", "I"+QString::number(instance)))
|
||||
, _instance(instance)
|
||||
, _sTable(new SettingsTable(instance, this))
|
||||
, _configVersion(DEFAULT_VERSION)
|
||||
@ -628,6 +628,8 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
|
||||
{
|
||||
newJsonConfig["port"] = 19444;
|
||||
}
|
||||
newJsonConfig["name"] = host;
|
||||
|
||||
json.append(newJsonConfig);
|
||||
migrated = true;
|
||||
}
|
||||
@ -636,13 +638,10 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
|
||||
|
||||
if (!json.isEmpty())
|
||||
{
|
||||
newForwarderConfig["json"] = json;
|
||||
}
|
||||
else
|
||||
{
|
||||
newForwarderConfig.remove("json");
|
||||
migrated = true;
|
||||
newForwarderConfig["jsonapi"] = json;
|
||||
}
|
||||
newForwarderConfig.remove("json");
|
||||
migrated = true;
|
||||
}
|
||||
|
||||
QJsonArray flatbuffer;
|
||||
@ -672,6 +671,7 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
|
||||
{
|
||||
newFlattbufferConfig["port"] = 19400;
|
||||
}
|
||||
newFlattbufferConfig["name"] = host;
|
||||
|
||||
flatbuffer.append(newFlattbufferConfig);
|
||||
migrated = true;
|
||||
@ -680,13 +680,10 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
|
||||
|
||||
if (!flatbuffer.isEmpty())
|
||||
{
|
||||
newForwarderConfig["flat"] = flatbuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
newForwarderConfig.remove("flat");
|
||||
migrated = true;
|
||||
newForwarderConfig["flatbuffer"] = flatbuffer;
|
||||
}
|
||||
newForwarderConfig.remove("flat");
|
||||
migrated = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,10 @@ void LedDeviceWrapper::createLedDevice(const QJsonObject& config)
|
||||
QThread* thread = new QThread(this);
|
||||
thread->setObjectName("LedDeviceThread");
|
||||
_ledDevice = LedDeviceFactory::construct(config);
|
||||
|
||||
QString subComponent = parent()->property("instance").toString();
|
||||
_ledDevice->setLogger(Logger::getInstance("LEDDEVICE", subComponent));
|
||||
|
||||
_ledDevice->moveToThread(thread);
|
||||
// setup thread management
|
||||
connect(thread, &QThread::started, _ledDevice, &LedDevice::start);
|
||||
@ -92,13 +96,13 @@ QJsonObject LedDeviceWrapper::getLedDeviceSchemas()
|
||||
QString devName = item.remove("schema-");
|
||||
|
||||
QString data;
|
||||
if(!FileUtils::readFile(schemaPath, data, Logger::getInstance("LedDevice")))
|
||||
if(!FileUtils::readFile(schemaPath, data, Logger::getInstance("LEDDEVICE")))
|
||||
{
|
||||
throw std::runtime_error("ERROR: Schema not found: " + item.toStdString());
|
||||
}
|
||||
|
||||
QJsonObject schema;
|
||||
if(!JsonUtils::parse(schemaPath, data, schema, Logger::getInstance("LedDevice")))
|
||||
if(!JsonUtils::parse(schemaPath, data, schema, Logger::getInstance("LEDDEVICE")))
|
||||
{
|
||||
throw std::runtime_error("ERROR: JSON schema wrong of file: " + item.toStdString());
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ QAtomicInteger<int> Logger::GLOBAL_MIN_LOG_LEVEL { static_cast<int>(Logger::U
|
||||
|
||||
namespace
|
||||
{
|
||||
const char * LogLevelStrings[] = { "", "DEBUG", "INFO", "WARNING", "ERROR" };
|
||||
const char * LogLevelStrings[] = { "", "DEBUG", "INFO", "WARNING", "ERROR", "OFF" };
|
||||
#ifndef _WIN32
|
||||
const int LogLevelSysLog[] = { LOG_DEBUG, LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERR };
|
||||
#endif
|
||||
@ -41,39 +41,16 @@ QAtomicInteger<unsigned int> LoggerId = 0;
|
||||
const int MaxRepeatCountSize = 200;
|
||||
QThreadStorage<int> RepeatCount;
|
||||
QThreadStorage<Logger::T_LOG_MESSAGE> RepeatMessage;
|
||||
|
||||
QString getApplicationName()
|
||||
{
|
||||
//#ifdef __GLIBC__
|
||||
// const char* _appname_char = program_invocation_short_name;
|
||||
//#elif !defined(_WIN32)
|
||||
// const char* _appname_char = getprogname();
|
||||
//#else
|
||||
// char fileName[MAX_PATH];
|
||||
// char *_appname_char;
|
||||
// HINSTANCE hinst = GetModuleHandle(NULL);
|
||||
// if (GetModuleFileNameA(hinst, fileName, sizeof(fileName)))
|
||||
// {
|
||||
// _appname_char = PathFindFileName(fileName);
|
||||
// *(PathFindExtension(fileName)) = 0;
|
||||
// }
|
||||
// else
|
||||
// _appname_char = "unknown";
|
||||
//#endif
|
||||
// return QString(_appname_char).toLower();
|
||||
//
|
||||
return "";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Logger* Logger::getInstance(const QString & name, Logger::LogLevel minLevel)
|
||||
Logger* Logger::getInstance(const QString & name, const QString & subName, Logger::LogLevel minLevel)
|
||||
{
|
||||
QMutexLocker lock(&MapLock);
|
||||
|
||||
Logger* log = LoggerMap.value(name, nullptr);
|
||||
Logger* log = LoggerMap.value(name + subName, nullptr);
|
||||
if (log == nullptr)
|
||||
{
|
||||
log = new Logger(name, minLevel);
|
||||
log = new Logger(name, subName, minLevel);
|
||||
LoggerMap.insert(name, log); // compat version, replace it with following line if we have 100% c++11
|
||||
//LoggerMap.emplace(name, log); // not compat with older linux distro's e.g. wheezy
|
||||
connect(log, &Logger::newLogMessage, LoggerManager::getInstance(), &LoggerManager::handleNewLogMessage);
|
||||
@ -82,25 +59,26 @@ Logger* Logger::getInstance(const QString & name, Logger::LogLevel minLevel)
|
||||
return log;
|
||||
}
|
||||
|
||||
void Logger::deleteInstance(const QString & name)
|
||||
void Logger::deleteInstance(const QString & name, const QString & subName)
|
||||
{
|
||||
QMutexLocker lock(&MapLock);
|
||||
|
||||
if (name.isEmpty())
|
||||
{
|
||||
for (auto logger : LoggerMap)
|
||||
for (auto *logger : qAsConst(LoggerMap)) {
|
||||
delete logger;
|
||||
}
|
||||
|
||||
LoggerMap.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete LoggerMap.value(name, nullptr);
|
||||
LoggerMap.remove(name);
|
||||
delete LoggerMap.value(name + subName, nullptr);
|
||||
LoggerMap.remove(name + subName);
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::setLogLevel(LogLevel level, const QString & name)
|
||||
void Logger::setLogLevel(LogLevel level, const QString & name, const QString & subName)
|
||||
{
|
||||
if (name.isEmpty())
|
||||
{
|
||||
@ -108,26 +86,26 @@ void Logger::setLogLevel(LogLevel level, const QString & name)
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger* log = Logger::getInstance(name, level);
|
||||
Logger* log = Logger::getInstance(name, subName, level);
|
||||
log->setMinLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
Logger::LogLevel Logger::getLogLevel(const QString & name)
|
||||
Logger::LogLevel Logger::getLogLevel(const QString & name, const QString & subName)
|
||||
{
|
||||
if (name.isEmpty())
|
||||
{
|
||||
return static_cast<Logger::LogLevel>(int(GLOBAL_MIN_LOG_LEVEL));
|
||||
}
|
||||
|
||||
const Logger* log = Logger::getInstance(name);
|
||||
const Logger* log = Logger::getInstance(name + subName);
|
||||
return log->getMinLevel();
|
||||
}
|
||||
|
||||
Logger::Logger (const QString & name, LogLevel minLevel)
|
||||
Logger::Logger (const QString & name, const QString & subName, LogLevel minLevel)
|
||||
: QObject()
|
||||
, _name(name)
|
||||
, _appname(getApplicationName())
|
||||
, _subname(subName)
|
||||
, _syslogEnabled(true)
|
||||
, _loggerId(LoggerId++)
|
||||
, _minLevel(static_cast<int>(minLevel))
|
||||
@ -139,7 +117,7 @@ Logger::Logger (const QString & name, LogLevel minLevel)
|
||||
#ifndef _WIN32
|
||||
if (_syslogEnabled)
|
||||
{
|
||||
openlog (_appname.toLocal8Bit(), LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL0);
|
||||
openlog (nullptr, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -172,7 +150,7 @@ void Logger::write(const Logger::T_LOG_MESSAGE & message)
|
||||
.arg(message.function);
|
||||
}
|
||||
|
||||
QString name = message.appName + " " + message.loggerName;
|
||||
QString name = "|" + message.loggerSubName + "| " + message.loggerName;
|
||||
name.resize(MAX_IDENTIFICATION_LENGTH, ' ');
|
||||
|
||||
const QDateTime timestamp = QDateTime::fromMSecsSinceEpoch(message.utime);
|
||||
@ -220,6 +198,7 @@ void Logger::Message(LogLevel level, const char* sourceFile, const char* func, u
|
||||
};
|
||||
|
||||
if (RepeatMessage.localData().loggerName == _name &&
|
||||
RepeatMessage.localData().loggerSubName == _subname &&
|
||||
RepeatMessage.localData().function == func &&
|
||||
RepeatMessage.localData().message == msg &&
|
||||
RepeatMessage.localData().line == line)
|
||||
@ -236,8 +215,8 @@ void Logger::Message(LogLevel level, const char* sourceFile, const char* func, u
|
||||
|
||||
Logger::T_LOG_MESSAGE logMsg;
|
||||
|
||||
logMsg.appName = _appname;
|
||||
logMsg.loggerName = _name;
|
||||
logMsg.loggerSubName = _subname;
|
||||
logMsg.function = QString(func);
|
||||
logMsg.line = line;
|
||||
logMsg.fileName = FileUtils::getBaseName(sourceFile);
|
||||
|
Loading…
Reference in New Issue
Block a user