LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
LLU::Logger Class Reference

Description

Logger class is responsible for sending log messages via WSTP to Mathematica.

It may be more convenient to use one of the LLU_DEBUG/WARNING/ERROR macros instead of calling Logger methods directly.

#include <Logger.h>

Public Types

enum  Level {
  Debug,
  Warning,
  Error
}
 Possible log severity levels. More...
 

Static Public Member Functions

template<Level L, typename... T>
static void log (WolframLibraryData libData, int line, const std::string &fileName, const std::string &function, T &&... args)
 Send a log message of given severity. More...
 
template<Level L, typename... T>
static void log (int line, const std::string &fileName, const std::string &function, T &&... args)
 Send a log message of given severity. More...
 
static std::string to_string (Level l)
 Converts Logger::Level value to std::string. More...
 
static void setContext (std::string context)
 Set new context for the top-level symbol that will handle logging. More...
 
static std::string getSymbol ()
 Get the top-level symbol with full context, to which all logs are sent. More...
 

Member Enumeration Documentation

◆ Level

enum LLU::Logger::Level
strong

Possible log severity levels.

Member Function Documentation

◆ getSymbol()

static std::string LLU::Logger::getSymbol ( )
inlinestatic

Get the top-level symbol with full context, to which all logs are sent.

Returns
top-level symbol to which logs are sent

◆ log() [1/2]

template<Logger::Level L, typename... T>
void LLU::Logger::log ( int  line,
const std::string &  fileName,
const std::string &  function,
T &&...  args 
)
static

Send a log message of given severity.

Template Parameters
L- log level, severity of the log
T- any number of WSTP-supported types
Parameters
line- line number where the log was called
fileName- name of the file in which the log was called
function- function in which the log was called
args- additional parameters carrying the actual log message contents
Warning
This function communicates with WSTP and if this communication goes wrong, WSStream may throw so be careful when logging in destructors.

◆ log() [2/2]

template<Logger::Level L, typename... T>
void LLU::Logger::log ( WolframLibraryData  libData,
int  line,
const std::string &  fileName,
const std::string &  function,
T &&...  args 
)
static

Send a log message of given severity.

Template Parameters
L- log level, severity of the log
T- any number of WSTP-supported types
Parameters
libData- WolframLibraryData, if nullptr - no logging happens
line- line number where the log was called
fileName- name of the file in which the log was called
function- function in which the log was called
args- additional parameters carrying the actual log message contents
Warning
This function communicates with WSTP and if this communication goes wrong, WSStream may throw so be careful when logging in destructors.

◆ setContext()

static void LLU::Logger::setContext ( std::string  context)
inlinestatic

Set new context for the top-level symbol that will handle logging.

Parameters
context- new context, must end with "`"

◆ to_string()

std::string LLU::Logger::to_string ( Level  l)
static

Converts Logger::Level value to std::string.

Parameters
l- log level
Returns
a string representation of the input log level