OSDN Git Service

Persist sorry server connection.
[ultramonkey-l7/ultramonkey-l7-v2.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 #include <stdlib.h>
31
32 #define BUF_LEN (4096)
33 #define DEBUG_STR_LEN (4096)
34 #define ADDR_STR_LEN (16)
35
36 namespace l7vs
37 {
38         /*!
39          *  Logger creation class.
40          *  this class create Logger Inmlement class and mediate function.
41          */
42         class Logger
43         {
44         public:
45                 //! default constructor creates implement class.
46                 Logger();
47                 //! destructor.
48                 ~Logger();
49                 /*!
50                  * returns single instance.
51                  *
52                  * @param   void
53                  * @return  instance
54                  */             
55                 static Logger& getInstance() {
56                         return instance;
57                 }
58                 //! load Configuration.
59                 void loadConf();
60                 //! retrieve category's log level.
61                 LOG_LEVEL_TAG getLogLevel(LOG_CATEGORY_TAG cat);
62                 //! set category's log level.
63                 bool setLogLevel(LOG_CATEGORY_TAG cat, LOG_LEVEL_TAG level);
64                 //! output fatal log.
65                 void putLogFatal(LOG_CATEGORY_TAG cat, const unsigned int message_id, const std::string& message, const char *file, int line);
66                 //! output error log.
67                 void putLogError(LOG_CATEGORY_TAG cat, const unsigned int message_id, const std::string& message, const char *file, int line);
68                 //! output warn log.
69                 void putLogWarn(LOG_CATEGORY_TAG cat, const unsigned int message_id, const std::string& message, const char *file, int line);
70                 //! output info log.
71                 void putLogInfo(LOG_CATEGORY_TAG cat, const unsigned int message_id, const std::string& message, const char *file, int line);
72                 //! output debug log.
73                 void putLogDebug(LOG_CATEGORY_TAG cat, const unsigned int message_id, const std::string& message, const char *file, int line);
74                 //! return start category by using module.
75                 LOG_CATEGORY_TAG getCategoryRangeStart(LOG_MODULE_TAG mod);
76                 //! return end category by using module.
77                 LOG_CATEGORY_TAG getCategoryRangeEnd(LOG_MODULE_TAG mod);
78
79         protected:
80                 /*!
81                  * static instance initialize before main. 
82                  * instance will defined in main program.
83                  */
84                 static Logger instance;
85         };
86 }       //namespace l7vs
87
88 #endif  //__LOGGER_H__