2 * @file logger_wapprer.h
3 * @brief logger module c wrapper.
5 * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6 * Copyright (C) 2008 NTT COMWARE Corporation.
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.
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.
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
23 **********************************************************************/
25 #ifndef __LOGGER_WRAPPER_H__
26 #define __LOGGER_WRAPPER_H__
31 * retrieve category's log level.
32 * this is only wrapper to implement method.
33 * @param category that want to know
36 inline enum LOG_LEVEL_TAG logger_get_log_level(const enum LOG_CATEGORY_TAG cat)
38 return l7vs::Logger::getInstance().getLogLevel(cat);
42 * set category's log level.
43 * this is only wrapper to implement method.
44 * @param category to set log level
49 inline int logger_set_log_level(const enum LOG_CATEGORY_TAG cat, const enum LOG_LEVEL_TAG level)
51 if (l7vs::Logger::getInstance().setLogLevel(cat, level)) {
59 * this is only wrapper to implement method.
60 * @param category that logging matter occured
61 * @param log message id
67 inline void logger_put_log_fatal(const enum LOG_CATEGORY_TAG cat, const unsigned int message_id, char* file, int line, const char* message)
69 l7vs::Logger::getInstance().putLogFatal(cat, message_id, message, file, line);
74 * this is only wrapper to implement method.
75 * @param category that logging matter occured
76 * @param log message id
82 inline void logger_put_log_error(const enum LOG_CATEGORY_TAG cat, const unsigned int message_id, char* file, int line, const char* message)
84 l7vs::Logger::getInstance().putLogError(cat, message_id, message, file, line);
89 * this is only wrapper to implement method.
90 * @param category that logging matter occured
91 * @param log message id
97 inline void logger_put_log_warn(const enum LOG_CATEGORY_TAG cat, const unsigned int message_id, char* file, int line, const char* message)
99 l7vs::Logger::getInstance().putLogWarn(cat, message_id, message, file, line);
104 * this is only wrapper to implement method.
105 * @param category that logging matter occured
106 * @param log message id
107 * @param current file
108 * @param current line
112 inline void logger_put_log_info(const enum LOG_CATEGORY_TAG cat, const unsigned int message_id, char* file, int line, const char* message)
114 l7vs::Logger::getInstance().putLogInfo(cat, message_id, message, file, line);
119 * this is only wrapper to implement method.
120 * @param category that logging matter occured
121 * @param log message id
122 * @param current file
123 * @param current line
127 inline void logger_put_log_debug(const enum LOG_CATEGORY_TAG cat, const unsigned int message_id, char* file, int line, const char* message)
129 l7vs::Logger::getInstance().putLogDebug(cat, message_id, message, file, line);
133 * return start category by using module.
134 * this is only wrapper to implement method.
136 * @retrun start category
138 inline enum LOG_CATEGORY_TAG logger_get_category_range_start(enum LOG_MODULE_TAG mod)
140 return l7vs::Logger::getInstance().getCategoryRangeStart(mod);
144 * return end category by using module.
145 * this is only wrapper to implement method.
147 * @retrun end category
149 inline enum LOG_CATEGORY_TAG logger_get_category_range_end(enum LOG_MODULE_TAG mod)
151 return l7vs::Logger::getInstance().getCategoryRangeEnd(mod);
154 #define LOGGER_PUT_LOG_FATAL(cat, message_id, message, arg...) { \
155 if (LOG_LV_FATAL >= logger_get_log_level(cat)) { \
157 snprintf(buf, BUF_LEN, message, ##arg); \
158 logger_put_log_fatal(cat, message_id, __FILE__, __LINE__, buf); }}
160 #define LOGGER_PUT_LOG_ERROR(cat, message_id, message, arg...) { \
161 if (LOG_LV_ERROR >= logger_get_log_level(cat)) { \
163 snprintf(buf, BUF_LEN, message, ##arg); \
164 logger_put_log_error(cat, message_id, __FILE__, __LINE__, buf); }}
166 #define LOGGER_PUT_LOG_WARN(cat, message_id, message, arg...) { \
167 if (LOG_LV_WARN >= logger_get_log_level(cat)) { \
169 snprintf(buf, BUF_LEN, message, ##arg); \
170 logger_put_log_warn(cat, message_id, __FILE__, __LINE__, buf); }}
172 #define LOGGER_PUT_LOG_INFO(cat, message_id, message, arg...) { \
173 if (LOG_LV_INFO >= logger_get_log_level(cat)) { \
175 snprintf(buf, BUF_LEN, message, ##arg); \
176 logger_put_log_info(cat, message_id, __FILE__, __LINE__, buf); }}
178 #define LOGGER_PUT_LOG_DEBUG(cat, message_id, message, arg...) { \
180 snprintf(buf, BUF_LEN, message, ##arg); \
181 logger_put_log_debug(cat, message_id, __FILE__, __LINE__, buf); }
183 #endif //__LOGGER_WRAPPER_H__