CUBRID Engine  latest
shard_proxy_log.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * shard_proxy_log.h -
22  */
23 
24 #ifndef _SHARD_PROXY_LOG_H_
25 #define _SHARD_PROXY_LOG_H_
26 
27 #ident "$Id$"
28 
29 #include <stdio.h>
30 #include <stdarg.h>
31 #include <stdlib.h>
32 #include <time.h>
33 #include <string.h>
34 #include <errno.h>
35 #if defined(WINDOWS)
36 #include <sys/timeb.h>
37 #include <process.h>
38 #else
39 #include <unistd.h>
40 #include <sys/time.h>
41 #endif
42 
43 #include "broker_shm.h"
44 #include "broker_config.h"
45 
46 extern void proxy_log_open (char *br_name, int proxy_index);
47 /* SHARD TODO : SUPPORT CUBRID MANAGER
48 extern void proxy_log_reset (char *br_name, int proxy_index);
49 */
50 extern void proxy_log_close (void);
51 extern void proxy_access_log_close (void);
52 extern void proxy_log_end (void);
53 extern void proxy_log_write (int level, char *svc_code, const char *fmt, ...);
54 extern int proxy_log_get_level (void);
55 
56 extern int proxy_access_log (struct timeval *start_time, int client_ip_addr, const char *dbname, const char *dbuser,
57  bool accepted);
58 
59 #if defined(WINDOWS)
60 #define PROXY_LOG(level, fmt, ...) \
61  do { \
62  if (level > PROXY_LOG_MODE_NONE \
63  && level <= PROXY_LOG_MODE_ALL \
64  && level <= proxy_log_get_level()) \
65  { \
66  proxy_log_write (level, \
67  NULL, "%s(%d): " fmt, \
68  __FILE__, __LINE__, \
69  __VA_ARGS__); \
70  } \
71  } while(0)
72 
73 #define PROXY_DEBUG_LOG(fmt, ...) \
74  do { \
75  if (PROXY_LOG_MODE_DEBUG <= proxy_log_get_level()) \
76  { \
77  proxy_log_write (PROXY_LOG_MODE_DEBUG, \
78  NULL, "%s(%d): " fmt, \
79  __FILE__, __LINE__, \
80  __VA_ARGS__); \
81  } \
82  } while(0)
83 #else /* WINDOWS */
84 #define PROXY_LOG(level, fmt, args...) \
85  do { \
86  if (level > PROXY_LOG_MODE_NONE \
87  && level <= PROXY_LOG_MODE_ALL \
88  && level <= proxy_log_get_level()) \
89  { \
90  proxy_log_write (level, \
91  NULL, "%s(%d): " fmt, \
92  __FILE__, __LINE__, \
93  ##args); \
94  } \
95  } while(0)
96 
97 #define PROXY_DEBUG_LOG(fmt, args...) \
98  do { \
99  if (PROXY_LOG_MODE_DEBUG <= proxy_log_get_level()) \
100  { \
101  proxy_log_write (PROXY_LOG_MODE_DEBUG, \
102  NULL, "%s(%d): " fmt, \
103  __FILE__, __LINE__, \
104  ##args); \
105  } \
106  } while(0)
107 #endif /* !WINDOWS */
108 
109 #if defined(NDEBUG) && defined(PROXY_VERBOSE_DEBUG)
110 #define ENTER_FUNC() PROXY_DEBUG_LOG("ENTER")
111 #else /* NDEBUG && PROXY_VERBOSE_DEBUG */
112 #define ENTER_FUNC()
113 #endif
114 
115 #if defined(NDEBUG) && defined(PROXY_VERBOSE_DEBUG)
116 #define EXIT_FUNC() PROXY_DEBUG_LOG("EXIT")
117 #else /* NDEBUG && PROXY_VERBOSE_DEBUG */
118 #define EXIT_FUNC()
119 #endif
120 
121 #if defined(NDEBUG) && defined(PROXY_VERBOSE_DEBUG)
122 #define DEBUG_FUNC() PROXY_DEBUG_LOG("DEBUG")
123 #else /* NDEBUG && PROXY_VERBOSE_DEBUG */
124 #define DEBUG_FUNC()
125 #endif
126 
127 #endif /* _SHARD_PROXY_LOG_H_ */
int proxy_access_log(struct timeval *start_time, int client_ip_addr, const char *dbname, const char *dbuser, bool accepted)
static char * dbuser
void proxy_log_end(void)
void proxy_access_log_close(void)
int proxy_log_get_level(void)
static char * dbname
static struct timeval start_time
void proxy_log_close(void)
void proxy_log_open(char *br_name, int proxy_index)
void proxy_log_write(int level, char *svc_code, const char *fmt,...)