CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::LogSystem Class Reference

Process-wide singleton logging hub with per-topic verbosity/debug levels. More...

#include <Utils.h>

Collaboration diagram for cmlabs::LogSystem:
[legend]

Public Member Functions

 LogSystem ()
 ~LogSystem ()

Static Public Member Functions

static bool SetLogReceiver (LogReceiver *rec)
 Register a receiver that gets every accepted LogEntry.
static bool SetLogFileOutput (const char *logfile, bool printOut=true)
 Direct log output to a file.
static bool SetLogLevelDebug (uint8 level)
 Set the debug level threshold for all topics.
static bool SetLogLevelDebug (uint8 subject, uint8 level)
 Set the debug level threshold for one topic.
static bool SetLogLevelVerbose (uint8 level)
 Set the verbose (print) level threshold for all topics.
static bool SetLogLevelVerbose (uint8 subject, uint8 level)
 Set the verbose (print) level threshold for one topic.
static bool LogSystemPrint (uint32 source, uint8 subject, uint8 level, const char *formatstring,...)
 printf-style informational logging (usually invoked via the LogPrint macro).
static bool LogSystemDebug (uint32 source, uint8 subject, uint8 level, const char *formatstring,...)
 printf-style debug logging (usually invoked via the LogDebug macro); same parameters as LogSystemPrint() but gated on the debug thresholds.

Public Attributes

uint8 logLevelVerbose [LOG_MAXCOUNT]
uint8 logLevelDebug [LOG_MAXCOUNT]
LogReceiver * logReceiverObj
char * logfile
bool printToStdOut

Static Public Attributes

static LogSystem * LogSingleton = NULL
 Lazily-created global instance used by all static functions.

Detailed Description

Process-wide singleton logging hub with per-topic verbosity/debug levels.

Log calls go through the LogPrint / LogDebug macros which forward to the static LogSystemPrint()/LogSystemDebug() printf-style entry points. Output can go to stdout, a file, and/or a registered LogReceiver. Topics (subjects) are the LOG_* constants above; each has independent verbose and debug level thresholds.

Definition at line 272 of file Utils.h.

Constructor & Destructor Documentation

◆ LogSystem()

cmlabs::LogSystem::LogSystem ( )

◆ ~LogSystem()

cmlabs::LogSystem::~LogSystem ( )

Definition at line 246 of file Utils.cpp.

References logfile, and printToStdOut.

Member Function Documentation

◆ LogSystemDebug()

bool cmlabs::LogSystem::LogSystemDebug ( uint32 source,
uint8 subject,
uint8 level,
const char * formatstring,
... )
static

◆ LogSystemPrint()

bool cmlabs::LogSystem::LogSystemPrint ( uint32 source,
uint8 subject,
uint8 level,
const char * formatstring,
... )
static

printf-style informational logging (usually invoked via the LogPrint macro).

Parameters
sourceNumeric id of the logging component.
subjectLOG_* topic.
levelImportance; emitted when <= the topic's verbose threshold.
formatstringprintf format followed by matching varargs.
Returns
true if the entry was emitted.

Definition at line 319 of file Utils.cpp.

References cmlabs::utils::AppendToAFile(), cmlabs::LogEntry::cid, cmlabs::GetTimeNow(), cmlabs::LogEntry::level, LOG_MAXCOUNT, LOGENTRYID, LOGPRINT, LogSingleton, LogSystem(), cmlabs::PrintTimeNowString(), cmlabs::LogEntry::setText(), cmlabs::LogEntry::size, cmlabs::LogEntry::source, cmlabs::utils::StringFormat(), cmlabs::utils::StringFormatVA(), cmlabs::LogEntry::subject, cmlabs::LogEntry::time, and cmlabs::LogEntry::type.

Referenced by _wrap_LogSystem_LogSystemPrint__varargs__().

◆ SetLogFileOutput()

bool cmlabs::LogSystem::SetLogFileOutput ( const char * logfile,
bool printOut = true )
static

Direct log output to a file.

Parameters
logfilePath of the log file to append to.
printOutAlso keep printing to stdout when true.
Returns
true if the file could be set.

Definition at line 288 of file Utils.cpp.

References LOG_MAXCOUNT, logfile, LogSingleton, LogSystem(), and cmlabs::utils::strcpyavail().

Referenced by _wrap_LogSystem_SetLogFileOutput__SWIG_0(), and _wrap_LogSystem_SetLogFileOutput__SWIG_1().

◆ SetLogLevelDebug() [1/2]

bool cmlabs::LogSystem::SetLogLevelDebug ( uint8 level)
static

Set the debug level threshold for all topics.

Parameters
levelMessages with level <= this are emitted.

Definition at line 193 of file Utils.cpp.

References LOG_MAXCOUNT, LogSingleton, and LogSystem().

Referenced by _wrap_LogSystem_SetLogLevelDebug__SWIG_0(), and _wrap_LogSystem_SetLogLevelDebug__SWIG_1().

◆ SetLogLevelDebug() [2/2]

bool cmlabs::LogSystem::SetLogLevelDebug ( uint8 subject,
uint8 level )
static

Set the debug level threshold for one topic.

Parameters
subjectLOG_* topic id.
levelThreshold.

Definition at line 204 of file Utils.cpp.

References LOG_MAXCOUNT, LogSingleton, and LogSystem().

◆ SetLogLevelVerbose() [1/2]

bool cmlabs::LogSystem::SetLogLevelVerbose ( uint8 level)
static

Set the verbose (print) level threshold for all topics.

Parameters
levelThreshold.

Definition at line 217 of file Utils.cpp.

References LOG_MAXCOUNT, LogSingleton, and LogSystem().

Referenced by _wrap_LogSystem_SetLogLevelVerbose__SWIG_0(), and _wrap_LogSystem_SetLogLevelVerbose__SWIG_1().

◆ SetLogLevelVerbose() [2/2]

bool cmlabs::LogSystem::SetLogLevelVerbose ( uint8 subject,
uint8 level )
static

Set the verbose (print) level threshold for one topic.

Parameters
subjectLOG_* topic id.
levelThreshold.

Definition at line 228 of file Utils.cpp.

References LOG_MAXCOUNT, LogSingleton, and LogSystem().

◆ SetLogReceiver()

bool cmlabs::LogSystem::SetLogReceiver ( LogReceiver * rec)
static

Register a receiver that gets every accepted LogEntry.

Parameters
recReceiver (not owned).
Returns
true on success.

Definition at line 182 of file Utils.cpp.

References LOG_MAXCOUNT, LogSingleton, and LogSystem().

Referenced by _wrap_LogSystem_SetLogReceiver(), and cmlabs::PsySpace::reset().

Member Data Documentation

◆ logfile

char* cmlabs::LogSystem::logfile

Definition at line 309 of file Utils.h.

Referenced by _wrap_LogSystem_logfile_set(), LogSystem(), SetLogFileOutput(), and ~LogSystem().

◆ logLevelDebug

uint8 cmlabs::LogSystem::logLevelDebug[LOG_MAXCOUNT]

Definition at line 307 of file Utils.h.

Referenced by _wrap_LogSystem_logLevelDebug_set().

◆ logLevelVerbose

uint8 cmlabs::LogSystem::logLevelVerbose[LOG_MAXCOUNT]

Definition at line 306 of file Utils.h.

Referenced by _wrap_LogSystem_logLevelVerbose_set().

◆ logReceiverObj

LogReceiver* cmlabs::LogSystem::logReceiverObj

Definition at line 308 of file Utils.h.

◆ LogSingleton

◆ printToStdOut

bool cmlabs::LogSystem::printToStdOut

Definition at line 310 of file Utils.h.

Referenced by LogSystem(), and ~LogSystem().


The documentation for this class was generated from the following files:
  • /home/ubuntu/c/partner/psyclone2/CMSDK/include/Utils.h
  • /home/ubuntu/c/partner/psyclone2/CMSDK/src/Utils.cpp