log2 replaced with Log2 inline function.

This commit is contained in:
Roland Jax
2014-11-21 21:49:40 +01:00
parent 8e37591ca7
commit 143de6f3b3
3 changed files with 14 additions and 10 deletions
+5 -5
View File
@@ -308,25 +308,25 @@ void BusLoop::analyseCycData()
static bool skipfirst = false; static bool skipfirst = false;
if (skipfirst == true) { if (skipfirst == true) {
L.log(bus, trace, "%s", m_sstr.getDataStr().c_str()); L.log(cyc, trace, "%s", m_sstr.getDataStr().c_str());
int index = m_commands->storeCycData(m_sstr.getDataStr()); int index = m_commands->storeCycData(m_sstr.getDataStr());
if (index == -1) { if (index == -1) {
L.log(bus, debug, " command not found"); L.log(cyc, debug, " command not found");
} }
else if (index == -2) { else if (index == -2) {
L.log(bus, debug, " no commands defined"); L.log(cyc, debug, " no commands defined");
} }
else if (index == -3) { else if (index == -3) {
L.log(bus, debug, " search skipped - string too short"); L.log(cyc, debug, " search skipped - string too short");
} }
else { else {
std::string tmp; std::string tmp;
tmp += (*m_commands)[index][1]; tmp += (*m_commands)[index][1];
tmp += " "; tmp += " ";
tmp += (*m_commands)[index][2]; tmp += (*m_commands)[index][2];
L.log(bus, event, " cycle [%4d] %s", index, tmp.c_str()); L.log(cyc, event, " cycle [%4d] %s", index, tmp.c_str());
} }
// collect Slave address // collect Slave address
+6 -3
View File
@@ -29,11 +29,14 @@
#include <unistd.h> #include <unistd.h>
/** static char array with logging area names */ /** static char array with logging area names */
static const char* AreaNames[Size_of_Areas] = { "bas", "net", "bus" }; static const char* AreaNames[Size_of_Areas] = { "bas", "net", "bus", "cyc" };
/** static char array with logging level names */ /** static char array with logging level names */
static const char* LevelNames[Size_of_Level] = { "error", "event", "trace", "debug" }; static const char* LevelNames[Size_of_Level] = { "error", "event", "trace", "debug" };
/** inline function of log2 */
inline double Log2(double n) { return log(n) / log(2); }
int calcAreas(const std::string areas) int calcAreas(const std::string areas)
{ {
int m_areas = 0; int m_areas = 0;
@@ -120,7 +123,7 @@ void* LogSink::run()
void LogConsole::write(const LogMessage& message) const void LogConsole::write(const LogMessage& message) const
{ {
std::cout << message.getTime() << " [" std::cout << message.getTime() << " ["
<< AreaNames[(int)log2(message.getArea())] << " " << AreaNames[(int)Log2(message.getArea())] << " "
<< LevelNames[message.getLevel()] << "] " << LevelNames[message.getLevel()] << "] "
<< message.getText() << std::endl; << message.getText() << std::endl;
} }
@@ -133,7 +136,7 @@ void LogFile::write(const LogMessage& message) const
if (file.is_open() == true) { if (file.is_open() == true) {
file << message.getTime() << " [" file << message.getTime() << " ["
<< AreaNames[(int)log2(message.getArea())] << " " << AreaNames[(int)Log2(message.getArea())] << " "
<< LevelNames[message.getLevel()] << "] " << LevelNames[message.getLevel()] << "] "
<< message.getText() << std::endl; << message.getText() << std::endl;
file.close(); file.close();
+3 -2
View File
@@ -33,8 +33,9 @@ enum AreasType {
bas=1, // basis bas=1, // basis
net=2, // network net=2, // network
bus=4, // ebus bus=4, // ebus
all=7, // type for all subsystems cyc=8, // cycle
Size_of_Areas=3, // number of possible areas all=15, // type for all subsystems
Size_of_Areas=4, // number of possible areas
}; };
/** available logging levels */ /** available logging levels */