Computer Assited Medical Intervention Tool Kit  version 4.0
Static Public Member Functions | Static Private Attributes | List of all members
camitk::Log Class Reference

This class is a log utility. More...

#include <Log.h>

Static Public Member Functions

static void closeLogFile ()
 Method used to close the log File. More...
 
static std::ostream * getLogStream ()
 get the logFile (singleton) More...
 
static bool getShowTime ()
 get show time information More...
 
static bool getShowUser ()
 get the status of show user information More...
 
static std::string getUserInformation ()
 get the user information More...
 
static void openLogFile ()
 Method used to open the log File. More...
 
static void showTime (bool)
 show date/time information in logs More...
 
static void showUser (bool)
 show or not the user information More...
 

Static Private Attributes

static std::ofstream * logFilePtr = NULL
 the log file More...
 
static bool showTimeInfo = false
 show time info More...
 
static bool showUserInfo = false
 show user info More...
 

Detailed Description

This class is a log utility.

It helps you to log messages anywhere in your code for different levels: CAMITK_INFO, CAMITK_ERROR, CAMITK_WARNING and CAMITK_DEBUG. Log macros CAMITK_INFO and CAMITK_ERROR are always enabled. Log macros CAMITK_WARNING and CAMITK_DEBUG are two optional macro, disabled by default.

Logs are defined by macros, which can be switch off at compile time. The log behaviour is defined directly by the value of 2 cmake variables: CAMITK_LOG_FILE and CAMITK_LOG_LEVEL.

For CAMITK_LOG_LEVEL consider the following table:

CAMITK_LOG_LEVELEnabled macros
1CAMITK_ERROR / CAMITK_WARNING
2CAMITK_ERROR / CAMITK_WARNING / CAMITK_DEBUG

For CAMITK_LOG_FILE: You can choose to save logs into "log.txt" file in the executable directory. If this file does not exist, it is automatically created when the application is executed. This option is configured by cmake variable CAMITK_LOG_FILE.

How to use the macro in the source:

Member Function Documentation

◆ closeLogFile()

void camitk::Log::closeLogFile ( )
static

Method used to close the log File.

References logFilePtr.

Referenced by camitk::Application::quitting().

◆ getLogStream()

std::ostream * camitk::Log::getLogStream ( )
static

get the logFile (singleton)

Returns
the currently opened ofstream or cout if the log file has not yet be opened

References logFilePtr.

◆ getShowTime()

bool camitk::Log::getShowTime ( )
static

get show time information

References showTimeInfo.

◆ getShowUser()

bool camitk::Log::getShowUser ( )
static

get the status of show user information

References showUserInfo.

◆ getUserInformation()

std::string camitk::Log::getUserInformation ( )
static

get the user information

◆ openLogFile()

void camitk::Log::openLogFile ( )
static

Method used to open the log File.

References logFilePtr.

Referenced by camitk::Application::Application().

◆ showTime()

void camitk::Log::showTime ( bool  show)
static

show date/time information in logs

References showTimeInfo.

◆ showUser()

void camitk::Log::showUser ( bool  show)
static

show or not the user information

References showUserInfo.

Member Data Documentation

◆ logFilePtr

std::ofstream * camitk::Log::logFilePtr = NULL
staticprivate

the log file

global instances

Referenced by closeLogFile(), getLogStream(), and openLogFile().

◆ showTimeInfo

bool camitk::Log::showTimeInfo = false
staticprivate

show time info

Referenced by getShowTime(), and showTime().

◆ showUserInfo

bool camitk::Log::showUserInfo = false
staticprivate

show user info

Referenced by getShowUser(), and showUser().


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