Slice Tools
  • Home
  • SourceForge Page


  • libFoundation
  • Home
  • Class Hierarchy
  • Class List
  • Class Members
  • Examples


  • SourceForge.net Logo
     

    Logger Class Reference

    #include <Logger.hh>

    List of all members.


    Detailed Description

    Manager for logging operations, acts as a backend to write to.

    Manages the map of all categories, takes LogMsg and writes them to open log files, handles default filter levels and message levels

    Examples:

    example-logging.cc.


    Public Member Functions

     Logger (const char *logfile, const char *errorfile, const std::string &programName, const std::string &invocation)
     Sets default values for class.

     ~Logger ()
     Deconstructor disables log, deletes categories, closes logfiles.

    void addLogfile (const char *filename, bool isLogFile=true)
     Add a log file to output list.

    void addOutputStream (std::ostream *os)
     Add an output stream to the list of streams to log to.

    void setFilterLevels (const std::string &filterLevels)
     Set the default filter level, and levels for multiple categories.

    bool hasFilterLevel () const
     Simple function to check if the default filter level has been set.

    MessageLevel getDefaultFilterLevel () const
     Gets the default filter level from category "MAIN".

    void setDefaultFilterLevel (MessageLevel filterLevel, bool forceFirstTime=false)
     Sets the default filter level for new categories and category "MAIN".

    void setDefaultFilterLevel (int filterLevel, bool forceFirstTime=false)
     Simple wrapper.

    MessageLevel getDefaultMessageLevel () const
     Gets the default message level from category "MAIN".

    void setDefaultMessageLevel (MessageLevel messageLevel)
     Sets the default message level and for category "MAIN".

    void setDefaultMessageLevel (int messageLevel)
     Simple wrapper.

    LogCategory getCategory (std::string categoryName, MessageLevel messageLevel=MESSAGE_LEVEL_DEFAULT, MessageLevel filterLevel=MESSAGE_LEVEL_DEFAULT)
     Gets a LogCategory wrapping the CategoryInformation of categoryName.

    CategoryInformationgetCategoryInformation (std::string categoryName, MessageLevel messageLevel=MESSAGE_LEVEL_DEFAULT, MessageLevel filterLevel=MESSAGE_LEVEL_DEFAULT)
     Utility Function to find the CategoryInformation for a given categoryName.

    LogCategory getLog ()
     Gets a LogCategory for category "MAIN".

    void enable ()
     Enables the log if it was previously disabled.

    void disable ()
     Disables the log for all messages if it was previously enabled.

    bool isEnabled () const
     Returns if log is currently enabled.

    void writeLog (LogMsg *logMsg, bool incrementCount=true, std::ostream *os=NULL)
     Takes a message, formats it, and logs it to log and possibly error file.


    Constructor & Destructor Documentation

    Logger::Logger const char *  logfile,
    const char *  errorfile,
    const std::string &  programName,
    const std::string &  invocation
     

    Sets default values for class.

    Note: Log is disabled until a filter level is set

    Creates a category named "MAIN" at defaults for message and filter levels
    default filterlevel to MESSAGE_LEVEL_DEBUG_HIGH
    default messagelevel to MESSAGE_LEVEL_DEBUG_HIGH

    Sets m_logEnabled to false

    Parameters:
    logfile Path to log to
    errorfile Path to write error messages to
    programName Name of program for FINISH message
    invocation Invocation of program for START message

    Logger::~Logger  ) 
     

    Deconstructor disables log, deletes categories, closes logfiles.


    Member Function Documentation

    void Logger::addLogfile const char *  filename,
    bool  isLogFile = true
     

    Add a log file to output list.

    Parameters:
    filename File to open
    isLogFile If File is for logging (vs error only)

    void Logger::addOutputStream std::ostream *  os  ) 
     

    Add an output stream to the list of streams to log to.

    void Logger::disable  ) 
     

    Disables the log for all messages if it was previously enabled.

    Writes close log sequence to log files

    See also:
    enable

    void Logger::enable  ) 
     

    Enables the log if it was previously disabled.

    Opens the log file if it is the first time the log is enabled

    See also:
    disable

    LogCategory Logger::getCategory std::string  categoryName,
    MessageLevel  messageLevel = MESSAGE_LEVEL_DEFAULT,
    MessageLevel  filterLevel = MESSAGE_LEVEL_DEFAULT
     

    Gets a LogCategory wrapping the CategoryInformation of categoryName.

    See also:
    getCategoryInformation
    Examples:
    example-logging.cc.

    CategoryInformation * Logger::getCategoryInformation std::string  categoryName,
    MessageLevel  messageLevel = MESSAGE_LEVEL_DEFAULT,
    MessageLevel  filterLevel = MESSAGE_LEVEL_DEFAULT
     

    Utility Function to find the CategoryInformation for a given categoryName.

    Returns the internal information for a category from the category map. If the category is not found, it is added to the map. Only Logger can create new CategoryInformation objects.

    Note: MESSAGE_LEVEL_DEFAULT means to use the existing level for existing categories or to use the default level for new categories.

    Parameters:
    categoryName Name of category to get
    messageLevel Message level of category to get
    filterLevel FilterLevel of category to get
    Returns:
    CategoryInformation of categoryName

    MessageLevel Logger::getDefaultFilterLevel  )  const
     

    Gets the default filter level from category "MAIN".

    Returns:
    Current filter level

    MessageLevel Logger::getDefaultMessageLevel  )  const
     

    Gets the default message level from category "MAIN".

    Returns:
    Current message level

    LogCategory Logger::getLog  ) 
     

    Gets a LogCategory for category "MAIN".

    bool Logger::hasFilterLevel  )  const
     

    Simple function to check if the default filter level has been set.

    bool Logger::isEnabled  )  const
     

    Returns if log is currently enabled.

    void Logger::setDefaultFilterLevel int  filterLevel,
    bool  forceFirstTime = false
     

    Simple wrapper.

    void Logger::setDefaultFilterLevel MessageLevel  filterLevel,
    bool  forceFirstTime = false
     

    Sets the default filter level for new categories and category "MAIN".

    Messages with a message level below the filter level are not written to the log.

    Parameters:
    filterLevel Filter level for all future categories
    forceFirstTime Force the firsttime enabled sequence, even if the default level is set to MESSAGE_LEVEL_OFF
    See also:
    CategoryInformation::setFilterLevel

    void Logger::setDefaultMessageLevel int  messageLevel  ) 
     

    Simple wrapper.

    void Logger::setDefaultMessageLevel MessageLevel  messageLevel  ) 
     

    Sets the default message level and for category "MAIN".

    Parameters:
    messageLevel New default message level

    void Logger::setFilterLevels const std::string &  filterLevels  ) 
     

    Set the default filter level, and levels for multiple categories.

    Syntax for setting multiple filter levels is:
    fl[,CATEGORY=fl[...]]
    fl means the filterlevel as a positive integer
    CATEGORY is the name of the category
    If no CATEGORY is provided, then the filterLevel will be set as the default

    Parameters:
    filterLevels String containing filterLevels to set

    void Logger::writeLog LogMsg logMsg,
    bool  incrementCount = true,
    std::ostream *  os = NULL
     

    Takes a message, formats it, and logs it to log and possibly error file.

    If it is a fatal error, also calls writeFatal().

    Note: Deletes logMsg when done.

    Parameters:
    logMsg Message to log
    incrementCount If this object should increment the global msg count
    os Output stream to write to, NULL means write to all output stream


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