Slice Tools
  • Home
  • SourceForge Page


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


  • SourceForge.net Logo
     

    LogCategory.hh

    Go to the documentation of this file.
    00001 // $Id: LogCategory.hh,v 1.1 2005/07/29 02:55:15 mschatz Exp $
    00002 
    00005 
    00006 #ifndef LOGCATEGORY_HH
    00007 #define LOGCATEGORY_HH 1
    00008 
    00009 #include <string>
    00010 #include <sstream>
    00011 #include "MessageLevel.hh"
    00012 
    00013 #include "Logger.hh"
    00014 #include "CategoryInformation.hh"
    00015 
    00016 using namespace std;
    00017 
    00018 
    00020 class LogStreamBuf : public std::stringbuf
    00021 {
    00022 public:
    00023   LogStreamBuf(LogCategory * category);
    00024   int sync();
    00025 
    00026 private:
    00028   LogCategory * m_category;
    00029 };
    00030 
    00031 
    00033 
    00038 class LogCategory : public std::ostream
    00039 {
    00040 public:
    00041   LogCategory(const LogCategory & input);
    00042   LogCategory(Logger * logger,
    00043               std::string categoryName,
    00044               MessageLevel messageLevel = MESSAGE_LEVEL_DEFAULT,
    00045               MessageLevel filterLevel = MESSAGE_LEVEL_DEFAULT);
    00046 
    00047   LogCategory(CategoryInformation * categoryInformation,
    00048               Logger * logger);
    00049   ~LogCategory();
    00050 
    00051   LogCategory & operator= (const LogCategory & input);
    00052 
    00053   // Get a different category from log manager
    00054   LogCategory getCategory(std::string categoryName,
    00055                           MessageLevel messageLevel = MESSAGE_LEVEL_DEFAULT,
    00056                           MessageLevel filterLevel = MESSAGE_LEVEL_DEFAULT);
    00057   
    00058   // Category Data Functions
    00059   std::string getCategoryName() const;
    00060 
    00061   MessageLevel getFilterLevel() const;
    00062   void         setFilterLevel(MessageLevel filterLevel);
    00063   void         setFilterLevel(int          filterLevel);
    00064 
    00065   MessageLevel getMessageLevel() const;
    00066   void         setMessageLevel(MessageLevel messageLevel);
    00067   void         setMessageLevel(int          messageLevel);
    00068 
    00069   void         pushMessageLevel(MessageLevel messageLevel);
    00070   void         pushMessageLevel(int          messageLevel);
    00071   void         popMessageLevel();
    00072 
    00073   // Category Management
    00074   void disable();
    00075 
    00076   // Log Messages
    00077   void logMsg(const std::string & msg, 
    00078               MessageLevel messageLevel=MESSAGE_LEVEL_DEFAULT) const;
    00079 
    00080   void debug       (const std::string & msg) const;
    00081   void debugH      (const std::string & msg) const;
    00082   void debugM      (const std::string & msg) const;
    00083   void debugL      (const std::string & msg) const;
    00084   void information (const std::string & msg) const;
    00085   void warning     (const std::string & msg) const;
    00086   void error       (const std::string & msg) const;
    00087   void fatal       (const std::string & msg) const;
    00088   void log         (const std::string & msg) const;
    00089 
    00090 private:
    00091   // ostream operations
    00092   LogStreamBuf * rdbuf()                   const;
    00093   std::string    str()                     const;
    00094   void           str(const std::string & s);
    00095   void           sync();
    00096   bool           m_alreadySyncing;
    00097   
    00099   CategoryInformation * m_category;
    00100 
    00102   Logger * m_logger;
    00103 
    00105   int m_pid;
    00106 
    00108   friend class LogStreamBuf;
    00109   LogStreamBuf sb;
    00110 };
    00111 
    00112 
    00113 
    00114 #endif