libyui  3.3.1
YUILog Class Reference

UI logging. More...

#include <YUILog.h>

Public Member Functions

std::ostream & log (YUILogLevel_t logLevel, const char *logComponent, const char *sourceFileName, int lineNo, const char *functionName)
 Generic log function. More...
 

Static Public Member Functions

static std::ostream & debug (const char *logComponent, const char *sourceFileName, int lineNo, const char *functionName)
 Logging functions for each log level. More...
 
static std::ostream & milestone (const char *logComponent, const char *sourceFileName, int lineNo, const char *functionName)
 
static std::ostream & warning (const char *logComponent, const char *sourceFileName, int lineNo, const char *functionName)
 
static std::ostream & error (const char *logComponent, const char *sourceFileName, int lineNo, const char *functionName)
 
static YUILoginstance ()
 Return the singleton object for this class. More...
 
static void enableDebugLogging (bool debugLogging=true)
 Enable or disable debug logging.
 
static bool debugLoggingEnabled ()
 Return 'true' if debug logging is enabled, 'false' if not.
 
static bool setLogFileName (const std::string &logFileName)
 Set the log file name to be used with the standard logger function. More...
 
static std::string logFileName ()
 Return the current log file name or an empty string if stderr is used. More...
 
static void setLoggerFunction (YUILoggerFunction loggerFunction)
 Set the UI logger function. More...
 
static YUILoggerFunction loggerFunction (bool returnStdLogger=false)
 Return the UI logger function. More...
 
static void setEnableDebugLoggingHooks (YUIEnableDebugLoggingFunction enableFunction, YUIDebugLoggingEnabledFunction isEnabledFunction)
 Set the hook functions to enable/disable debug logging and to query if debug logging is enabled: More...
 
static YUIEnableDebugLoggingFunction enableDebugLoggingHook ()
 Return the hook function that enables or disables debug logging or 0 if no such hook function is set.
 
static YUIDebugLoggingEnabledFunction debugLoggingEnabledHook ()
 Return the hook function that checks if debug logging is enabled or 0 if no such hook function is set.
 
static std::string basename (const std::string &fileNameWithPath)
 Return the base name without path from a file name with path.
 

Detailed Description

UI logging.

Definition at line 97 of file YUILog.h.

Member Function Documentation

◆ debug()

std::ostream & YUILog::debug ( const char *  logComponent,
const char *  sourceFileName,
int  lineNo,
const char *  functionName 
)
static

Logging functions for each log level.

They all access the singleton object for this class. This means that the first call to any of those functions will create the singleton YUILog object.

Definition at line 483 of file YUILog.cc.

◆ instance()

YUILog * YUILog::instance ( )
static

Return the singleton object for this class.

This will create the singleton if it doesn't exist yet.

Definition at line 329 of file YUILog.cc.

◆ log()

std::ostream & YUILog::log ( YUILogLevel_t  logLevel,
const char *  logComponent,
const char *  sourceFileName,
int  lineNo,
const char *  functionName 
)

Generic log function.

debug(), milestone() etc. ultimately all call this function.

Definition at line 452 of file YUILog.cc.

Here is the call graph for this function:

◆ logFileName()

std::string YUILog::logFileName ( )
static

Return the current log file name or an empty string if stderr is used.

Notice that this information is only relevant as long as the standard logger function is used.

Definition at line 380 of file YUILog.cc.

◆ loggerFunction()

YUILoggerFunction YUILog::loggerFunction ( bool  returnStdLogger = false)
static

Return the UI logger function.

If stderr is used for logging (i.e. no logger function set), 0 is returned (unless 'returnStdLogger' is 'true', in which case the internally used stderr-logger is returned).

Definition at line 417 of file YUILog.cc.

◆ setEnableDebugLoggingHooks()

void YUILog::setEnableDebugLoggingHooks ( YUIEnableDebugLoggingFunction  enableFunction,
YUIDebugLoggingEnabledFunction  isEnabledFunction 
)
static

Set the hook functions to enable/disable debug logging and to query if debug logging is enabled:

void enableDebugLogging( bool enable ); bool debugLoggingEnabled();

If those functions are set, they will be used instead of the internal "debugLogging" flag.

Definition at line 429 of file YUILog.cc.

◆ setLogFileName()

bool YUILog::setLogFileName ( const std::string &  logFileName)
static

Set the log file name to be used with the standard logger function.

Output will be appended to this file.

Until this file name is set, the standard logger function logs to stderr. Set the log file name to an empty string to log to stderr again.

This returns 'true' upon success (opening the file was successful), 'false' upon error.

Notice:

(1) This file name is only relevant as long as the standard logger function is used. Custom logger functions may or may not use this file name.

(2) No attempt is made to do anything fancy with the log file like log file rotation when a certain file size is reached. Applications that need this should use a custom logger function. See also setLoggerFunction().

Definition at line 344 of file YUILog.cc.

◆ setLoggerFunction()

void YUILog::setLoggerFunction ( YUILoggerFunction  loggerFunction)
static

Set the UI logger function.

This is the function that will ultimately receive all UI log output (except debug logging if debug logging is disabled).

By default, all logging is output to stderr. This behaviour can be restored if 0 is passed as a function pointer here.

Definition at line 407 of file YUILog.cc.


The documentation for this class was generated from the following files: