mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Alejandro changes from ESRF
This commit is contained in:
parent
44339d3b89
commit
e2d1d58acf
@ -95,7 +95,7 @@ class ThreadObject : private virtual slsReceiverDefs {
|
|||||||
bool alive;
|
bool alive;
|
||||||
|
|
||||||
/** Variable monitored by thread to kills itself */
|
/** Variable monitored by thread to kills itself */
|
||||||
bool killThread;
|
volatile bool killThread;
|
||||||
|
|
||||||
/** Thread variable */
|
/** Thread variable */
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
|
@ -126,7 +126,8 @@ bool CircularFifo<Element>::isEmpty() const
|
|||||||
template<typename Element>
|
template<typename Element>
|
||||||
bool CircularFifo<Element>::isFull() const
|
bool CircularFifo<Element>::isFull() const
|
||||||
{
|
{
|
||||||
int tailCheck = (tail+1) % Capacity;
|
int tailCheck = increment(tail);
|
||||||
|
//int tailCheck = (tail+1) % Capacity;
|
||||||
return (tailCheck == head);
|
return (tailCheck == head);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,14 +125,18 @@ inline std::string NowTime()
|
|||||||
inline std::string NowTime()
|
inline std::string NowTime()
|
||||||
{
|
{
|
||||||
char buffer[11];
|
char buffer[11];
|
||||||
|
const int buffer_len = sizeof(buffer);
|
||||||
time_t t;
|
time_t t;
|
||||||
time(&t);
|
time(&t);
|
||||||
tm r = {0};
|
tm r = {0};
|
||||||
strftime(buffer, sizeof(buffer), "%X", localtime_r(&t, &r));
|
strftime(buffer, buffer_len, "%X", localtime_r(&t, &r));
|
||||||
|
buffer[buffer_len - 1] = 0;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, 0);
|
gettimeofday(&tv, 0);
|
||||||
char result[100] = {0};
|
char result[100];
|
||||||
sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000);
|
const int result_len = sizeof(result);
|
||||||
|
snprintf(result, result_len, "%s.%03ld", buffer, (long)tv.tv_usec / 1000);
|
||||||
|
result[result_len - 1] = 0;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +150,8 @@ template <typename T> std::ostringstream& Log<T>::Get(TLogLevel level)
|
|||||||
lev = level;
|
lev = level;
|
||||||
os << "- " << NowTime();
|
os << "- " << NowTime();
|
||||||
os << " " << ToString(level) << ": ";
|
os << " " << ToString(level) << ": ";
|
||||||
os << std::string(level > logDEBUG ? level - logDEBUG : 0, '\t');
|
if (level > logDEBUG)
|
||||||
|
os << std::string(level - logDEBUG, '\t');
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,14 +223,15 @@ inline void Output2FILE::Output(const std::string& msg, TLogLevel level)
|
|||||||
FILE* pStream = Stream();
|
FILE* pStream = Stream();
|
||||||
if (!pStream)
|
if (!pStream)
|
||||||
return;
|
return;
|
||||||
|
bool out = true;
|
||||||
switch(level){
|
switch(level){
|
||||||
case logERROR: cprintf(RED BOLD,"%s",msg.c_str()); break;
|
case logERROR: cprintf(RED BOLD,"%s",msg.c_str()); break;
|
||||||
case logWARNING: cprintf(YELLOW BOLD,"%s",msg.c_str()); break;
|
case logWARNING: cprintf(YELLOW BOLD,"%s",msg.c_str()); break;
|
||||||
case logINFO: cprintf(GRAY,"%s",msg.c_str());break;
|
case logINFO: cprintf(GRAY,"%s",msg.c_str()); break;
|
||||||
// case logINFO: cprintf(DARKGRAY BOLD,"%s",msg.c_str());break;
|
// case logINFO: cprintf(DARKGRAY BOLD,"%s",msg.c_str());break;
|
||||||
default: fprintf(pStream,"%s",msg.c_str()); break;
|
default: fprintf(pStream,"%s",msg.c_str()); out = false; break;
|
||||||
}
|
}
|
||||||
fflush(pStream);
|
fflush(out ? stdout : pStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user