OSDN Git Service

1ea56fc20129c20d07288f2ca41ec47d5f357663
[ultramonkey-l7/sslproxy.git] / logger / logger.h
1 /*
2  * @file  logger.h
3  * @brief logger module creation class.
4  *
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6  * Copyright (C) 2008  NTT COMWARE Corporation.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *      
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  **********************************************************************/
24
25 #ifndef __LOGGER_H__
26 #define __LOGGER_H__
27
28 #include <string>
29 #include <logger_enum.h>
30
31 #define BUF_LEN (4096)
32 #define DEBUG_STR_LEN (4096)
33
34 namespace l7vs
35 {
36         /*!
37          *  Logger creation class.
38          *  this class create Logger Inmlement class and mediate function.
39          */
40         class Logger
41         {
42         public:
43                 //! default constructor creates implement class.
44                 Logger();
45                 //! destructor.
46                 ~Logger();
47                 /*!
48                  * returns single instance.
49                  *
50                  * @param   void
51                  * @return  instance
52                  */             
53                 static Logger& getInstance() {
54                         return instance;
55                 }
56                 //! load Configuration.
57                 void loadConf();
58                 //! retrieve category's log level.
59                 LOG_LEVEL_TAG getLogLevel(LOG_CATEGORY_TAG cat);
60                 //! set category's log level.
61                 bool setLogLevel(LOG_CATEGORY_TAG cat, LOG_LEVEL_TAG level);
62                 //! output fatal log.
63                 void putLogFatal(LOG_CATEGORY_TAG cat, const unsigned int message_id, const std::string& message, const char *file, int line);
64                 //! output error log.
65                 void putLogError(LOG_CATEGORY_TAG cat, const unsigned int message_id, const std::string& message, const char *file, int line);
66                 //! output warn log.
67                 void putLogWarn(LOG_CATEGORY_TAG cat, const unsigned int message_id, const std::string& message, const char *file, int line);
68                 //! output info log.
69                 void putLogInfo(LOG_CATEGORY_TAG cat, const unsigned int message_id, const std::string& message, const char *file, int line);
70                 //! output debug log.
71                 void putLogDebug(LOG_CATEGORY_TAG cat, const unsigned int message_id, const std::string& message, const char *file, int line);
72
73         protected:
74                 /*!
75                  * static instance initialize before main. 
76                  * instance will defined in main program.
77                  */
78                 static Logger instance;
79         };
80 }       //namespace l7vs
81
82 #endif  //__LOGGER_H__