2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 /***************************************************************************
19 * Description: Logger object definitions *
20 * Author: Gal Shachor <shachor@il.ibm.com> *
21 * Version: $Revision: 1001219 $ *
22 ***************************************************************************/
27 #include "jk_global.h"
34 #define JK_TIME_MAX_SIZE (64)
36 typedef struct jk_logger jk_logger_t;
41 const char *log_fmt; /* the configured timestamp format for logging */
42 char log_fmt_subsec[JK_TIME_MAX_SIZE]; /* like log_fmt, but milli/micro seconds marker
43 replaced, because strftime() doesn't handle those */
44 int log_fmt_type; /* do we want milli or microseconds */
45 size_t log_fmt_offset; /* at which position should we insert */
46 size_t log_fmt_size; /* how long is this format string */
48 int (JK_METHOD * log) (jk_logger_t *l, int level, int used, char *what);
52 typedef struct jk_file_logger_t jk_file_logger_t;
53 struct jk_file_logger_t
56 /* For Apache 2 APR piped logging */
58 /* For Apache 1.3 piped logging */
62 /* Level like Java tracing, but available only
63 at compile time on DEBUG preproc define.
65 #define JK_LOG_TRACE_LEVEL 0
66 #define JK_LOG_DEBUG_LEVEL 1
67 #define JK_LOG_INFO_LEVEL 2
68 #define JK_LOG_WARNING_LEVEL 3
69 #define JK_LOG_ERROR_LEVEL 4
70 #define JK_LOG_EMERG_LEVEL 5
71 #define JK_LOG_REQUEST_LEVEL 6
72 #define JK_LOG_DEF_LEVEL JK_LOG_INFO_LEVEL
74 #define JK_LOG_TRACE_VERB "trace"
75 #define JK_LOG_DEBUG_VERB "debug"
76 #define JK_LOG_INFO_VERB "info"
77 #define JK_LOG_WARN_VERB "warn"
78 #define JK_LOG_ERROR_VERB "error"
79 #define JK_LOG_EMERG_VERB "emerg"
80 #define JK_LOG_DEF_VERB JK_LOG_INFO_VERB
82 #if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER > 1200))
83 #define JK_LOG_TRACE __FILE__,__LINE__,__FUNCTION__,JK_LOG_TRACE_LEVEL
84 #define JK_LOG_DEBUG __FILE__,__LINE__,__FUNCTION__,JK_LOG_DEBUG_LEVEL
85 #define JK_LOG_ERROR __FILE__,__LINE__,__FUNCTION__,JK_LOG_ERROR_LEVEL
86 #define JK_LOG_EMERG __FILE__,__LINE__,__FUNCTION__,JK_LOG_EMERG_LEVEL
87 #define JK_LOG_INFO __FILE__,__LINE__,__FUNCTION__,JK_LOG_INFO_LEVEL
88 #define JK_LOG_WARNING __FILE__,__LINE__,__FUNCTION__,JK_LOG_WARNING_LEVEL
90 #define JK_LOG_TRACE __FILE__,__LINE__,NULL,JK_LOG_TRACE_LEVEL
91 #define JK_LOG_DEBUG __FILE__,__LINE__,NULL,JK_LOG_DEBUG_LEVEL
92 #define JK_LOG_ERROR __FILE__,__LINE__,NULL,JK_LOG_ERROR_LEVEL
93 #define JK_LOG_EMERG __FILE__,__LINE__,NULL,JK_LOG_EMERG_LEVEL
94 #define JK_LOG_INFO __FILE__,__LINE__,NULL,JK_LOG_INFO_LEVEL
95 #define JK_LOG_WARNING __FILE__,__LINE__,NULL,JK_LOG_WARNING_LEVEL
98 #define JK_LOG_REQUEST __FILE__,0,NULL,JK_LOG_REQUEST_LEVEL
100 #if defined(JK_PRODUCTION)
101 /* TODO: all DEBUG messages should be compiled out
102 * when this define is in place.
104 #define JK_IS_PRODUCTION 1
105 #define JK_TRACE_ENTER(l)
106 #define JK_TRACE_EXIT(l)
108 #define JK_IS_PRODUCTION 0
109 #define JK_TRACE_ENTER(l) \
111 if ((l) && (l)->level == JK_LOG_TRACE_LEVEL) { \
112 int tmp_errno = errno; \
113 jk_log((l), JK_LOG_TRACE, "enter"); \
117 #define JK_TRACE_EXIT(l) \
119 if ((l) && (l)->level == JK_LOG_TRACE_LEVEL) { \
120 int tmp_errno = errno; \
121 jk_log((l), JK_LOG_TRACE, "exit"); \
125 #endif /* JK_PRODUCTION */
127 #define JK_LOG_NULL_PARAMS(l) jk_log((l), JK_LOG_ERROR, "NULL parameters")
130 * It is more efficient to check the level prior
131 * calling function that will not execute anyhow because of level
133 #define JK_IS_DEBUG_LEVEL(l) ((l) && (l)->level < JK_LOG_INFO_LEVEL)
138 #endif /* __cplusplus */
139 #endif /* JK_LOGGER_H */