logstream#

class logstream#

Class to manage the debug logging stream.

Public Functions

void requestConsole(bool ignoreErrors)#

Helper force a console on platforms where it might optional, when we need to show a console. This basically means Windows at the moment - on other platforms it’s a no-op

void setLogLevels(sgDebugClass c, sgDebugPriority p, const std::string &tag = "console")#

Set the log class and priority level.

Parameters:
  • c – debug class

  • p – priority

  • tag – optional tag to identify the target of the log level change, for example “console” or “file”

std::string getLogClassesAsString() const#

Get the Log Classes as a string, in the format which could be passed tp parseLogClasses.

void setDeveloperMode(bool devMode)#

set developer mode on/off. In developer mode, SG_DEV_WARN messages are treated as warnings. In normal (non-developer) mode they are treated as SG_DEBUG.

bool inDeveloperMode() const#

check if developer mode is set or not

void setFileLine(bool fileLine)#

set output of file:line mode on/off. If on, all log messages are prefixed by the file:line of the caller of SG_LOG().

void log(sgDebugClass c, sgDebugPriority p, const char *fileName, int line, const char *function, const std::string &msg)#

the core logging method

void hexdump(sgDebugClass c, sgDebugPriority p, const char *fileName, int line, const char *function, const void *mem, unsigned int len, unsigned int columns = 16)#

output formatted hex dump of memory block

void popup(const std::string &msg)#

support for the SG_POPUP logging class set the content of the popup message

std::string get_popup()#

retrieve the contents of the popup message and clear it’s internal content. The return value may be an empty string.

bool has_popup()#

return true if a new popup message is available. false otherwise.

void addCallback(simgear::LogCallback *cb)#

register a logging callback. Note callbacks are run in a dedicated thread, so callbacks which pass data to other threads must use appropriate locking.

void setStartupLoggingEnabled(bool enabled)#

optionally record all entries and submit them to new log callbacks that are added. This allows simplified logging configuration, but still including early startup information in all logs.

void setTestingMode(bool testMode)#

Set up the logstream for running in test mode. For example the callbacks will be unregistered and the behaviour of the would_log() function sanitized.

Public Static Functions

static void disableStderrLogging()#

prevent logging to stderr, when we are outputting information on stdout for an early exit (eg version info or JSON report)

friend logstream &sglog()#

Return the one and only logstream instance. We use a function instead of a global object so we are assured that cerr has been initialised.

Returns:

current logstream

class LogStreamPrivate : public SGThread#

Public Functions

inline virtual void run() override#

All threads execute by deriving the run() method of SGThread. If this function terminates then the thread also terminates.

Public Members

CallbackVec m_consoleCallbacks#

subset of callbacks which correspond to stdout / console, and hence should dynamically reflect console logging settings