Revert "Logging API changes"
This is causing perf impact, so reverting until we figure out
a lower-impact solution.
This reverts commit 1be3e5771a.
This commit is contained in:
@@ -52,7 +52,7 @@ BufferedLogCallback::BufferedLogCallback(sgDebugClass c, sgDebugPriority p) :
|
|||||||
|
|
||||||
BufferedLogCallback::~BufferedLogCallback()
|
BufferedLogCallback::~BufferedLogCallback()
|
||||||
{
|
{
|
||||||
for (unsigned char* msg : d->m_buffer) {
|
BOOST_FOREACH(unsigned char* msg, d->m_buffer) {
|
||||||
free(msg);
|
free(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ public:
|
|||||||
/// for broken PUI behaviour, it can be removed once PUI is gone.
|
/// for broken PUI behaviour, it can be removed once PUI is gone.
|
||||||
void truncateAt(unsigned int);
|
void truncateAt(unsigned int);
|
||||||
|
|
||||||
void operator()(sgDebugClass c, sgDebugPriority p,
|
virtual void operator()(sgDebugClass c, sgDebugPriority p,
|
||||||
const char* file, int line, const std::string& aMessage) override;
|
const char* file, int line, const std::string& aMessage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read the stamp value associated with the log buffer. This is
|
* read the stamp value associated with the log buffer. This is
|
||||||
|
|||||||
+27
-12
@@ -398,8 +398,6 @@ public:
|
|||||||
/// and hence should dynamically reflect console logging settings
|
/// and hence should dynamically reflect console logging settings
|
||||||
CallbackVec m_consoleCallbacks;
|
CallbackVec m_consoleCallbacks;
|
||||||
|
|
||||||
std::vector<std::string> m_popupMessages;
|
|
||||||
|
|
||||||
sgDebugClass m_logClass;
|
sgDebugClass m_logClass;
|
||||||
sgDebugPriority m_logPriority;
|
sgDebugPriority m_logPriority;
|
||||||
bool m_isRunning = false;
|
bool m_isRunning = false;
|
||||||
@@ -508,11 +506,25 @@ public:
|
|||||||
PauseThread pause(this);
|
PauseThread pause(this);
|
||||||
m_logPriority = p;
|
m_logPriority = p;
|
||||||
m_logClass = c;
|
m_logClass = c;
|
||||||
for (auto cb : m_consoleCallbacks) {
|
BOOST_FOREACH(simgear::LogCallback* cb, m_consoleCallbacks) {
|
||||||
cb->setLogLevels(c, p);
|
cb->setLogLevels(c, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool would_log( sgDebugClass c, sgDebugPriority p ) const
|
||||||
|
{
|
||||||
|
// Testing mode, so always log.
|
||||||
|
if (m_testMode) return true;
|
||||||
|
|
||||||
|
// SG_OSG (OSG notify) - will always be displayed regardless of FG log settings as OSG log level is configured
|
||||||
|
// separately and thus it makes more sense to allow these message through.
|
||||||
|
if (p == SG_OSG) return true;
|
||||||
|
|
||||||
|
p = translatePriority(p);
|
||||||
|
if (p >= SG_INFO) return true;
|
||||||
|
return ((c & m_logClass) != 0 && p >= m_logPriority);
|
||||||
|
}
|
||||||
|
|
||||||
void log( sgDebugClass c, sgDebugPriority p,
|
void log( sgDebugClass c, sgDebugPriority p,
|
||||||
const char* fileName, int line, const std::string& msg)
|
const char* fileName, int line, const std::string& msg)
|
||||||
{
|
{
|
||||||
@@ -548,6 +560,7 @@ logstream::logstream()
|
|||||||
|
|
||||||
logstream::~logstream()
|
logstream::~logstream()
|
||||||
{
|
{
|
||||||
|
popup_msgs.clear();
|
||||||
d->stop();
|
d->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,10 +598,6 @@ logstream::log( sgDebugClass c, sgDebugPriority p,
|
|||||||
|
|
||||||
void logstream::hexdump(sgDebugClass c, sgDebugPriority p, const char* fileName, int line, const void *mem, unsigned int len, unsigned int columns)
|
void logstream::hexdump(sgDebugClass c, sgDebugPriority p, const char* fileName, int line, const void *mem, unsigned int len, unsigned int columns)
|
||||||
{
|
{
|
||||||
if (((c & d->m_logClass) == 0) || (p < d->m_logPriority)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
char temp[3000], temp1[3000];
|
char temp[3000], temp1[3000];
|
||||||
*temp = 0;
|
*temp = 0;
|
||||||
@@ -644,17 +653,17 @@ void logstream::hexdump(sgDebugClass c, sgDebugPriority p, const char* fileName,
|
|||||||
void
|
void
|
||||||
logstream::popup( const std::string& msg)
|
logstream::popup( const std::string& msg)
|
||||||
{
|
{
|
||||||
d->m_popupMessages.push_back(msg);
|
popup_msgs.push_back(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
logstream::get_popup()
|
logstream::get_popup()
|
||||||
{
|
{
|
||||||
std::string rv = "";
|
std::string rv = "";
|
||||||
if (!d->m_popupMessages.empty())
|
if (!popup_msgs.empty())
|
||||||
{
|
{
|
||||||
rv = d->m_popupMessages.front();
|
rv = popup_msgs.front();
|
||||||
d->m_popupMessages.erase(d->m_popupMessages.begin());
|
popup_msgs.erase(popup_msgs.begin());
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@@ -662,7 +671,13 @@ logstream::get_popup()
|
|||||||
bool
|
bool
|
||||||
logstream::has_popup()
|
logstream::has_popup()
|
||||||
{
|
{
|
||||||
return !d->m_popupMessages.empty();
|
return (popup_msgs.size() > 0) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
logstream::would_log( sgDebugClass c, sgDebugPriority p ) const
|
||||||
|
{
|
||||||
|
return d->would_log(c,p);
|
||||||
}
|
}
|
||||||
|
|
||||||
sgDebugClass
|
sgDebugClass
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <simgear/debug/debug_types.h>
|
#include <simgear/debug/debug_types.h>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
// forward decls
|
// forward decls
|
||||||
@@ -92,6 +93,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setLogLevels( sgDebugClass c, sgDebugPriority p );
|
void setLogLevels( sgDebugClass c, sgDebugPriority p );
|
||||||
|
|
||||||
|
bool would_log( sgDebugClass c, sgDebugPriority p ) const;
|
||||||
|
|
||||||
void logToFile( const SGPath& aPath, sgDebugClass c, sgDebugPriority p );
|
void logToFile( const SGPath& aPath, sgDebugClass c, sgDebugPriority p );
|
||||||
|
|
||||||
void set_log_priority( sgDebugPriority p);
|
void set_log_priority( sgDebugPriority p);
|
||||||
@@ -176,6 +179,8 @@ private:
|
|||||||
// constructor
|
// constructor
|
||||||
logstream();
|
logstream();
|
||||||
|
|
||||||
|
std::vector<std::string> popup_msgs;
|
||||||
|
|
||||||
class LogStreamPrivate;
|
class LogStreamPrivate;
|
||||||
|
|
||||||
std::unique_ptr<LogStreamPrivate> d;
|
std::unique_ptr<LogStreamPrivate> d;
|
||||||
@@ -192,17 +197,17 @@ logstream& sglog();
|
|||||||
* @param M message
|
* @param M message
|
||||||
*/
|
*/
|
||||||
# define SG_LOGX(C,P,M) \
|
# define SG_LOGX(C,P,M) \
|
||||||
do { \
|
do { if(sglog().would_log(C,P)) { \
|
||||||
std::ostringstream os; os << M; \
|
std::ostringstream os; os << M; \
|
||||||
sglog().log(C, P, __FILE__, __LINE__, os.str()); \
|
sglog().log(C, P, __FILE__, __LINE__, os.str()); \
|
||||||
if ((P) == SG_POPUP) sglog().popup(os.str()); \
|
if ((P) == SG_POPUP) sglog().popup(os.str()); \
|
||||||
} while(0)
|
} } while(0)
|
||||||
#ifdef FG_NDEBUG
|
#ifdef FG_NDEBUG
|
||||||
# define SG_LOG(C,P,M) do { if((P) == SG_POPUP) SG_LOGX(C,P,M) } while(0)
|
# define SG_LOG(C,P,M) do { if((P) == SG_POPUP) SG_LOGX(C,P,M) } while(0)
|
||||||
# define SG_HEXDUMP(C,P,MEM,LEN)
|
# define SG_HEXDUMP(C,P,MEM,LEN)
|
||||||
#else
|
#else
|
||||||
# define SG_LOG(C,P,M) SG_LOGX(C,P,M)
|
# define SG_LOG(C,P,M) SG_LOGX(C,P,M)
|
||||||
# define SG_LOG_HEXDUMP(C,P,MEM,LEN) sglog().hexdump(C, P, __FILE__, __LINE__, MEM, LEN)
|
# define SG_LOG_HEXDUMP(C,P,MEM,LEN) if(sglog().would_log(C,P)) sglog().hexdump(C, P, __FILE__, __LINE__, MEM, LEN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SG_ORIGIN __FILE__ ":" SG_STRINGIZE(__LINE__)
|
#define SG_ORIGIN __FILE__ ":" SG_STRINGIZE(__LINE__)
|
||||||
|
|||||||
Reference in New Issue
Block a user