Commit 937a7c2a authored by Michael Ott's avatar Michael Ott
Browse files

Cosmetic changes to plugin configuration debug output

parent 2eb99c13
......@@ -265,14 +265,15 @@ public:
}
}
virtual void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "Sensor: " << _name;
//LOG_VAR(ll) << leading << " MQTT Topic: " << _mqtt;
LOG_VAR(ll) << leading << " SubSampling: " << getSubsampling();
LOG_VAR(ll) << leading << (_skipConstVal ? " Skipping constant values" : " No skipping of constant values");
LOG_VAR(ll) << leading << (_delta ? " Storing delta readings" : " Storing absolute readings");
virtual void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << _name;
if (getSubsampling() != 1) {
LOG_VAR(ll) << leading << " SubSampling: " << getSubsampling();
}
LOG_VAR(ll) << leading << " Skip const values: " << (_skipConstVal ? "true" : "false");
LOG_VAR(ll) << leading << " Store delta only: " << (_delta ? "true" : "false");
}
protected:
......
......@@ -174,7 +174,6 @@ protected:
*/
virtual void printConfiguratorConfig(LOG_LEVEL ll) {
//Overwrite if necessary
LOG_VAR(ll) << " No other plugin-specific general parameters or entities defined";
}
/**
......
......@@ -324,19 +324,26 @@ public:
//prints plugin specific configurator attributes and entities if present
printConfiguratorConfig(ll);
LOG_VAR(ll) << " " << _entityName << "s:";
LOG_VAR(ll) << " " << _entityName << "s:";
if (_sensorEntitys.size() != 0) {
for(auto e : _sensorEntitys) {
e->printConfig(ll);
e->printConfig(ll, 8);
LOG_VAR(ll) << " Sensor Groups:";
for(auto g : _sensorGroups) {
if (g->getEntity() == e) {
g->printConfig(ll, 16);
}
}
}
} else {
LOG_VAR(ll) << " No " << _entityName << "s present!";
LOG_VAR(ll) << " No " << _entityName << "s present!";
}
/*
LOG_VAR(ll) << " " << _groupName << "s:";
for(auto g : _sensorGroups) {
g->printConfig(ll);
}
*/
}
protected:
......
......@@ -34,9 +34,6 @@
#include "logging.h"
/** Indentation when printing configuration */
#define eInd " "
/**
* @brief Abstract interface defining sensor entity functionality.
*
......@@ -148,13 +145,14 @@ public:
*
* @param ll Log severity level to be used from logger.
*/
void printConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " " << "Entity " << _name;
LOG_VAR(ll) << eInd << "Disabled: " << (_disabled ? std::string("true") : std::string("false"));
void printConfig(LOG_LEVEL ll, unsigned int leadingSpaces) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << _name;
LOG_VAR(ll) << leading << " Disabled: " << (_disabled ? std::string("true") : std::string("false"));
if (_mqttPart != "") {
LOG_VAR(ll) << eInd << "MQTT part: " << _mqttPart;
LOG_VAR(ll) << leading << " MQTT part: " << _mqttPart;
}
this->printEntityConfig(ll);
this->printEntityConfig(ll, leadingSpaces+4);
}
protected:
......@@ -173,7 +171,7 @@ protected:
*
* @param ll Log severity level to be used from logger.
*/
virtual void printEntityConfig(LOG_LEVEL ll) { /* do nothing if not overwritten */ }
virtual void printEntityConfig(LOG_LEVEL ll, unsigned int leadingSpaces) { /* do nothing if not overwritten */ }
std::string _name; ///< Name of the entity
std::string _mqttPart; ///< Partial MQTT topic identifying this entity
......
......@@ -200,21 +200,17 @@ public:
*
* @param ll Log severity level to be used from logger.
*/
virtual void printConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " Sensor Group: " << _groupName;
LOG_VAR(ll) << " Disabled: " << (_disabled ? std::string("true") : std::string("false"));
virtual void printConfig(LOG_LEVEL ll, unsigned leadingSpaces=8) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << _groupName;
LOG_VAR(ll) << leading << " Disabled: " << (_disabled ? std::string("true") : std::string("false"));
if (_mqttPart != "") {
LOG_VAR(ll) << " MQTT part: " << _mqttPart;
LOG_VAR(ll) << leading << " MQTT part: " << _mqttPart;
}
if (_sync) {
LOG_VAR(ll) << " Synchronized readings enabled";
} else {
LOG_VAR(ll) << " Synchronized readings disabled";
}
LOG_VAR(ll) << " minValues: " << _minValues;
LOG_VAR(ll) << " interval: " << _interval;
LOG_VAR(ll) << leading << " Synchronized: " << (_sync ? std::string("true") : std::string("false"));
LOG_VAR(ll) << leading << " minValues: " << _minValues;
LOG_VAR(ll) << leading << " interval: " << _interval;
}
///@}
......@@ -266,8 +262,7 @@ protected:
*
* @param ll Severity level to log with
*/
virtual void printGroupConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " No other plugin-specific group attributes defined";
virtual void printGroupConfig(LOG_LEVEL ll, unsigned int leadingSpaces) {
}
///@}
......
......@@ -233,24 +233,19 @@ public:
*
* @param ll Log severity level to be used from logger.
*/
virtual void printConfig(LOG_LEVEL ll) final override {
virtual void printConfig(LOG_LEVEL ll, unsigned leadingSpaces=8) final override {
//print common base attributes
SensorGroupInterface::printConfig(ll);
SensorGroupInterface::printConfig(ll, leadingSpaces);
//print plugin specific group attributes
this->printGroupConfig(ll);
if (_entity) {
LOG_VAR(ll) << " Entity " << _entity->getName();
} else {
LOG_VAR(ll) << " No entity set!";
}
this->printGroupConfig(ll, leadingSpaces+4);
//print associated sensors
LOG_VAR(ll) << " Sensors:";
std::string leading(leadingSpaces+4, ' ');
LOG_VAR(ll) << leading << "Sensors:";
for(auto s : _sensors) {
s->SensorBase::printConfig(ll, lg);
s->printConfig(ll, lg);
s->SensorBase::printConfig(ll, lg, leadingSpaces+8);
s->printConfig(ll, lg, leadingSpaces+8);
}
}
......@@ -457,18 +452,19 @@ public:
*
* @param ll Log severity level to be used from logger.
*/
virtual void printConfig(LOG_LEVEL ll) final override {
virtual void printConfig(LOG_LEVEL ll, unsigned leadingSpaces=8) final override {
//print common base attributes
SensorGroupInterface::printConfig(ll);
SensorGroupInterface::printConfig(ll, leadingSpaces);
//print plugin specific group attributes
this->printGroupConfig(ll);
this->printGroupConfig(ll, leadingSpaces+4);
//print associated sensors
LOG_VAR(ll) << " Sensors:";
std::string leading(leadingSpaces+4, ' ');
LOG_VAR(ll) << leading << "Sensors:";
for(auto s : _sensors) {
s->SensorBase::printConfig(ll, lg);
s->printConfig(ll, lg);
s->SensorBase::printConfig(ll, lg, leadingSpaces+8);
s->printConfig(ll, lg, leadingSpaces+8);
}
}
......
......@@ -299,7 +299,8 @@ void BACnetClient::rejectHandler(BACNET_ADDRESS * src, uint8_t invokeId, uint8_t
throw std::runtime_error(str + errorMsg);
}
void BACnetClient::printEntityConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << eInd << "Timeout: " << _timeout;
void BACnetClient::printEntityConfig(LOG_LEVEL ll, unsigned int leadingSpaces) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "Timeout: " << _timeout;
}
......@@ -111,7 +111,7 @@ public:
*
* @param ll Log severity level to be used from logger.
*/
void printEntityConfig(LOG_LEVEL ll) override;
void printEntityConfig(LOG_LEVEL ll, unsigned int leadingSpaces) override;
private:
......
......@@ -91,13 +91,10 @@ void BACnetConfigurator::global(CFG_VAL config) {
return;
}
}
void BACnetConfigurator::printConfiguratorConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " No other plugin specific general attributes";
if (_bacClient) {
_bacClient->printConfig(ll);
_bacClient->printConfig(ll, 8);
} else {
LOG_VAR(ll) << " No BACClient present!";
LOG_VAR(ll) << " No BACClient present!";
}
}
......@@ -64,6 +64,7 @@ void BACnetSensorGroup::read() {
}
void BACnetSensorGroup::printGroupConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " deviceInstance: " << _deviceInstance;
void BACnetSensorGroup::printGroupConfig(LOG_LEVEL ll, unsigned int leadingSpaces) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "deviceInstance: " << _deviceInstance;
}
......@@ -47,7 +47,7 @@ public:
void setDeviceInstance(const std::string& deviceInstance) { _deviceInstance = stoul(deviceInstance); }
uint32_t getDeviceInstance() const { return _deviceInstance; }
void printGroupConfig(LOG_LEVEL ll) final override;
void printGroupConfig(LOG_LEVEL ll, unsigned int leadingSpaces) final override;
private:
void read() final override;
......
......@@ -97,8 +97,8 @@ void IPMIConfigurator::global(CFG_VAL config) {
}
void IPMIConfigurator::printConfiguratorConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " Session Timeout: " << _globalHost.sessionTimeout;
LOG_VAR(ll) << " Retransmission Timeout: " << _globalHost.retransmissionTimeout;
LOG_VAR(ll) << " Temporal write dir: " << _tempdir;
LOG_VAR(ll) << " Session Timeout: " << _globalHost.sessionTimeout;
LOG_VAR(ll) << " Retransmission Timeout: " << _globalHost.retransmissionTimeout;
LOG_VAR(ll) << " Temporal write dir: " << _tempdir;
}
......@@ -297,19 +297,23 @@ void IPMIHost::increaseErrorCount() {
}
}
void IPMIHost::printEntityConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << eInd << "IPMIHost: " << getHostName();
LOG_VAR(ll) << eInd << "UserName: " << getUserName();
void IPMIHost::printEntityConfig(LOG_LEVEL ll, unsigned int leadingSpaces) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "UserName: " << getUserName();
#ifdef DEBUG
LOG_VAR(ll) << eInd << "Password: " << getPassword();
LOG_VAR(ll) << leading << "Password: " << getPassword();
#else
LOG_VAR(ll) << eInd << "Password not shown";
LOG_VAR(ll) << leading << "Password: <not shown>";
#endif
LOG_VAR(ll) << eInd << "Cache: " << getCache();
LOG_VAR(ll) << eInd << "Auth: " << getAuth();
LOG_VAR(ll) << eInd << "Priv: " << getPriv();
LOG_VAR(ll) << eInd << "Cipher: " << getCipher();
LOG_VAR(ll) << eInd << "IPMI Version: " << getIpmiVersion();
LOG_VAR(ll) << eInd << "Session Timeout: " << _sessionTimeout;
LOG_VAR(ll) << eInd << "Retransmission Timeout: " << _retransmissionTimeout;
LOG_VAR(ll) << leading << "Cache: " << getCache();
LOG_VAR(ll) << leading << "IPMI Version: " << (int) getIpmiVersion();
if (getIpmiVersion() == 1) {
LOG_VAR(ll) << leading << "Auth: " << (int) getAuth();
}
LOG_VAR(ll) << leading << "Priv: " << (int) getPriv();
if (getIpmiVersion() == 2) {
LOG_VAR(ll) << leading << "Cipher: " << (int) getCipher();
}
LOG_VAR(ll) << leading << "Session Timeout: " << _sessionTimeout;
LOG_VAR(ll) << leading << "Retransmission Timeout: " << _retransmissionTimeout;
}
......@@ -78,7 +78,7 @@ public:
const std::string& getUserName() const { return _userName; }
uint64_t getDelayNextReadUntil() const { return _delayNextReadUntil; }
void printEntityConfig(LOG_LEVEL ll) final override;
void printEntityConfig(LOG_LEVEL ll, unsigned int leadingSpaces) final override;
private:
/* Open/close connection to BMC (sets/destroys _ipmiCtx) */
......
......@@ -148,20 +148,20 @@ public:
void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << " Type: " << getTypeString();
LOG_VAR(ll) << leading << " Type: " << getTypeString();
switch(_type) {
case raw:
LOG_VAR(ll) << leading << " Raw Cmd: " << getRawCmdString();
LOG_VAR(ll) << leading << " lsb: " << (int) _lsb;
LOG_VAR(ll) << leading << " msb: " << (int) _msb;
LOG_VAR(ll) << leading << " Raw Cmd: " << getRawCmdString();
LOG_VAR(ll) << leading << " lsb: " << (int) _lsb;
LOG_VAR(ll) << leading << " msb: " << (int) _msb;
break;
case sdr:
LOG_VAR(ll) << leading << " Record Id: " << _recordId;
LOG_VAR(ll) << leading << " Record Id: " << _recordId;
break;
default:
break;
}
LOG_VAR(ll) << leading << " Factor: " << _factor;
LOG_VAR(ll) << leading << " Factor: " << _factor;
}
protected:
......
......@@ -244,7 +244,7 @@ std::vector<unsigned> MSRSensorGroup::getCpus() {
return cpus;
}
void MSRSensorGroup::printGroupConfig(LOG_LEVEL ll) {
void MSRSensorGroup::printGroupConfig(LOG_LEVEL ll, unsigned int leadingSpaces) {
std::stringstream ss;
const char* separator = "";
for (unsigned int cpu=0; cpu < _sensorBins.size(); ++cpu) {
......@@ -253,6 +253,6 @@ void MSRSensorGroup::printGroupConfig(LOG_LEVEL ll) {
separator = ", ";
}
}
LOG_VAR(ll) << " CPUs: " << ss.str();
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "CPUs: " << ss.str();
}
......@@ -54,7 +54,7 @@ public:
void addCpu(unsigned int cpu);
std::vector<unsigned> getCpus();
void printGroupConfig(LOG_LEVEL ll) final override;
void printGroupConfig(LOG_LEVEL ll, unsigned int leadingSpaces) final override;
void setHtAggregation(unsigned int htAggregation) {
_htAggregation = htAggregation;
......
......@@ -195,7 +195,8 @@ void OpaSensorGroup::read() {
}
}
void OpaSensorGroup::printGroupConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " HFI Num: " << _hfiNum;
LOG_VAR(ll) << " Port Num: " << _portNum;
void OpaSensorGroup::printGroupConfig(LOG_LEVEL ll, unsigned int leadingSpaces) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "HFI Num: " << _hfiNum;
LOG_VAR(ll) << leading << "Port Num: " << _portNum;
}
......@@ -56,7 +56,7 @@ public:
void setHfiNum(const std::string& hfiNum) { _hfiNum = stoi(hfiNum); }
void setPortNum(const std::string& portNum) { _portNum = stoull(portNum); }
void printGroupConfig(LOG_LEVEL ll) final override;
void printGroupConfig(LOG_LEVEL ll, unsigned int leadingSpaces) final override;
private:
void read() final override;
......
......@@ -125,6 +125,7 @@ void PDUSensorGroup::read() {
}
}
void PDUSensorGroup::printGroupConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " Request: " << _request;
void PDUSensorGroup::printGroupConfig(LOG_LEVEL ll, unsigned int leadingSpaces) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "Request: " << _request;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment