eget: Status printing, do not dump stack trace if not in debug mode
This commit is contained in:
@@ -62,6 +62,11 @@ namespace epics {
|
||||
g_pvAccessLogLevel = level;
|
||||
}
|
||||
|
||||
bool pvAccessIsLoggable(pvAccessLogLevel level)
|
||||
{
|
||||
return level >= g_pvAccessLogLevel;
|
||||
}
|
||||
|
||||
class FileLogger : public NoDefaultMethods {
|
||||
public:
|
||||
FileLogger(String const & name) {
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace pvAccess {
|
||||
|
||||
void pvAccessLog(pvAccessLogLevel level, const char* format, ...);
|
||||
void pvAccessSetLogLevel(pvAccessLogLevel level);
|
||||
bool pvAccessIsLoggable(pvAccessLogLevel level);
|
||||
|
||||
#if defined (__GNUC__) && __GNUC__ < 3
|
||||
#define LOG(level, format, ARGS...) pvAccessLog(level, format, ##ARGS)
|
||||
@@ -45,7 +46,8 @@ namespace pvAccess {
|
||||
#define LOG(level, format, ...) pvAccessLog(level, format, ##__VA_ARGS__)
|
||||
#endif
|
||||
#define SET_LOG_LEVEL(level) pvAccessSetLogLevel(level)
|
||||
|
||||
#define IS_LOGGABLE(level) pvAccessIsLoggable(level)
|
||||
|
||||
// EPICS errlog
|
||||
//#define LOG errlogSevPrintf
|
||||
//#define SET_LOG_LEVEL(level) errlogSetSevToLog(level)
|
||||
|
||||
@@ -931,7 +931,7 @@ public:
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] channel get create: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] channel get create: " << status << std::endl;
|
||||
}
|
||||
|
||||
// assign smart pointers
|
||||
@@ -946,7 +946,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] failed to create channel get: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] failed to create channel get: " << status << std::endl;
|
||||
m_event.signal();
|
||||
}
|
||||
}
|
||||
@@ -958,7 +958,7 @@ public:
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] channel get: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] channel get: " << status << std::endl;
|
||||
}
|
||||
|
||||
// access smart pointers
|
||||
@@ -982,7 +982,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] failed to get: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] failed to get: " << status << std::endl;
|
||||
{
|
||||
Lock lock(m_pointerMutex);
|
||||
// this is OK since caller holds also owns it
|
||||
@@ -1047,7 +1047,7 @@ public:
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] channel RPC create: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] channel RPC create: " << status << std::endl;
|
||||
}
|
||||
|
||||
// assign smart pointers
|
||||
@@ -1060,7 +1060,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] failed to create channel get: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] failed to create channel get: " << status << std::endl;
|
||||
m_connectionEvent.signal();
|
||||
}
|
||||
}
|
||||
@@ -1072,7 +1072,7 @@ public:
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] channel RPC: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] channel RPC: " << status << std::endl;
|
||||
}
|
||||
|
||||
// access smart pointers
|
||||
@@ -1093,7 +1093,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] failed to RPC: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] failed to RPC: " << status << std::endl;
|
||||
{
|
||||
Lock lock(m_pointerMutex);
|
||||
// this is OK since caller holds also owns it
|
||||
|
||||
@@ -130,7 +130,7 @@ class ChannelGetRequesterImpl : public ChannelGetRequester
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] channel get create: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] channel get create: " << status << std::endl;
|
||||
}
|
||||
|
||||
// assign smart pointers
|
||||
@@ -145,7 +145,7 @@ class ChannelGetRequesterImpl : public ChannelGetRequester
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] failed to create channel get: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] failed to create channel get: " << status << std::endl;
|
||||
m_event.signal();
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class ChannelGetRequesterImpl : public ChannelGetRequester
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] channel get: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] channel get: " << status << std::endl;
|
||||
}
|
||||
|
||||
// access smart pointers
|
||||
@@ -181,7 +181,7 @@ class ChannelGetRequesterImpl : public ChannelGetRequester
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] failed to get: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] failed to get: " << status << std::endl;
|
||||
{
|
||||
Lock lock(m_pointerMutex);
|
||||
// this is OK since caller holds also owns it
|
||||
@@ -247,13 +247,13 @@ class MonitorRequesterImpl : public MonitorRequester
|
||||
// TODO and exit
|
||||
if (!startStatus.isSuccess())
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] channel monitor start: " << startStatus.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] channel monitor start: " << startStatus << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "monitorConnect(" << status.toString() << ")" << std::endl;
|
||||
std::cerr << "monitorConnect(" << status << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -641,7 +641,7 @@ class ChannelPutRequesterImpl : public ChannelPutRequester
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] channel put create: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] channel put create: " << status << std::endl;
|
||||
}
|
||||
|
||||
// assign smart pointers
|
||||
@@ -660,7 +660,7 @@ class ChannelPutRequesterImpl : public ChannelPutRequester
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] failed to create channel put: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] failed to create channel put: " << status << std::endl;
|
||||
m_event->signal();
|
||||
}
|
||||
}
|
||||
@@ -672,7 +672,7 @@ class ChannelPutRequesterImpl : public ChannelPutRequester
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] channel get: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] channel get: " << status << std::endl;
|
||||
}
|
||||
|
||||
m_done.set();
|
||||
@@ -696,7 +696,7 @@ class ChannelPutRequesterImpl : public ChannelPutRequester
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] failed to get: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] failed to get: " << status << std::endl;
|
||||
}
|
||||
|
||||
m_event->signal();
|
||||
@@ -709,14 +709,14 @@ class ChannelPutRequesterImpl : public ChannelPutRequester
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] channel put: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] channel put: " << status << std::endl;
|
||||
}
|
||||
|
||||
m_done.set();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "[" << m_channelName << "] failed to put: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channelName << "] failed to put: " << status << std::endl;
|
||||
}
|
||||
|
||||
m_event->signal();
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
#include <pv/logger.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace std::tr1;
|
||||
using namespace epics::pvData;
|
||||
@@ -29,6 +31,29 @@ void RequesterImpl::message(String const & message, MessageType messageType)
|
||||
std::cerr << "[" << getRequesterName() << "] message(" << message << ", " << getMessageTypeName(messageType) << ")" << std::endl;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& o, const Status& s)
|
||||
{
|
||||
o << '[' << Status::StatusTypeName[s.getType()] << "] ";
|
||||
String msg = s.getMessage();
|
||||
if (!msg.empty())
|
||||
{
|
||||
o << msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
o << "(no error message)";
|
||||
}
|
||||
// dump stack trace only if on debug mode
|
||||
if (IS_LOGGABLE(logLevelDebug))
|
||||
{
|
||||
String sd = s.getStackDump();
|
||||
if (!sd.empty())
|
||||
{
|
||||
o << std::endl << sd;
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
char separator = ' ';
|
||||
void terseSeparator(char c)
|
||||
@@ -203,12 +228,12 @@ void ChannelRequesterImpl::channelCreated(const epics::pvData::Status& status, C
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << channel->getChannelName() << "] channel create: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << channel->getChannelName() << "] channel create: " << status << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "[" << channel->getChannelName() << "] failed to create a channel: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << channel->getChannelName() << "] failed to create a channel: " << status << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +281,7 @@ void GetFieldRequesterImpl::getDone(const epics::pvData::Status& status, epics::
|
||||
// show warning
|
||||
if (!status.isOK())
|
||||
{
|
||||
std::cerr << "[" << m_channel->getChannelName() << "] getField create: " << status.toString() << std::endl;
|
||||
std::cerr << "[" << m_channel->getChannelName() << "] getField create: " << status << std::endl;
|
||||
}
|
||||
|
||||
// assign smart pointers
|
||||
@@ -268,7 +293,7 @@ void GetFieldRequesterImpl::getDone(const epics::pvData::Status& status, epics::
|
||||
else
|
||||
{
|
||||
// do not complain about missing field
|
||||
//std::cerr << "[" << m_channel->getChannelName() << "] failed to get channel introspection data: " << status.toString() << std::endl;
|
||||
//std::cerr << "[" << m_channel->getChannelName() << "] failed to get channel introspection data: " << status << std::endl;
|
||||
}
|
||||
|
||||
m_event.signal();
|
||||
|
||||
@@ -86,3 +86,4 @@ class GetFieldRequesterImpl :
|
||||
bool waitUntilFieldGet(double timeOut);
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& o, const epics::pvData::Status& s);
|
||||
|
||||
Reference in New Issue
Block a user