# axutil_log.h

    00001
    00002 /*
    00003  * Licensed to the Apache Software Foundation (ASF) under one or more
    00004  * contributor license agreements.  See the NOTICE file distributed with
    00005  * this work for additional information regarding copyright ownership.
    00006  * The ASF licenses this file to You under the Apache License, Version 2.0
    00007  * (the "License"); you may not use this file except in compliance with
    00008  * the License.  You may obtain a copy of the License at
    00009  *
    00010  *      http://www.apache.org/licenses/LICENSE-2.0
    00011  *
    00012  * Unless required by applicable law or agreed to in writing, software
    00013  * distributed under the License is distributed on an "AS IS" BASIS,
    00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00015  * See the License for the specific language governing permissions and
    00016  * limitations under the License.
    00017  */
    00018
    00019 #ifndef AXUTIL_LOG_H
    00020 #define AXUTIL_LOG_H
    00021
    00022 #include <axutil_allocator.h>
    00023
    00024 #ifdef __cplusplus
    00025 extern "C"
    00026 {
    00027 #endif
    00028
    00029     typedef struct axutil_log_ops axutil_log_ops_t;
    00030     typedef struct axutil_log axutil_log_t;
    00031
    00032 #define AXIS2_LOG_SI __FILE__,__LINE__
    00033
    00057     typedef enum axutil_log_levels
    00058     {
    00059
    00061         AXIS2_LOG_LEVEL_CRITICAL = 0,
    00062
    00064         AXIS2_LOG_LEVEL_ERROR,
    00065
    00067         AXIS2_LOG_LEVEL_WARNING,
    00068
    00070         AXIS2_LOG_LEVEL_INFO,
    00071
    00073         AXIS2_LOG_LEVEL_DEBUG,
    00074
    00076         AXIS2_LOG_LEVEL_USER,
    00077
    00079         AXIS2_LOG_LEVEL_TRACE
    00080
    00081     } axutil_log_levels_t;
    00082
    00088     struct axutil_log_ops
    00089     {
    00090
    00096         void(
    00097             AXIS2_CALL
    00098             * free)(
    00099                 axutil_allocator_t * allocator,
    00100                 struct axutil_log * log);
    00101
    00108         void(
    00109             AXIS2_CALL
    00110             * write)(
    00111                 axutil_log_t * log,
    00112                 const axis2_char_t * buffer,
    00113                 axutil_log_levels_t level,
    00114                 const axis2_char_t * file,
    00115                 const int line);
    00116     };
    00117
    00123     struct axutil_log
    00124     {
    00125
    00127         const axutil_log_ops_t *ops;
    00128
    00130         axutil_log_levels_t level;
    00131
    00133         int size;
    00134
    00136         axis2_bool_t enabled;
    00137
    00138     };
    00139
    00140     AXIS2_EXTERN void AXIS2_CALL
    00141     axutil_log_impl_log_critical(
    00142         axutil_log_t * log,
    00143         const axis2_char_t * filename,
    00144         const int linenumber,
    00145         const axis2_char_t * format,
    00146         ...);
    00147
    00148     AXIS2_EXTERN void AXIS2_CALL
    00149     axutil_log_impl_log_error(
    00150         axutil_log_t * log,
    00151         const axis2_char_t * filename,
    00152         const int linenumber,
    00153         const axis2_char_t * format,
    00154         ...);
    00155
    00156     AXIS2_EXTERN void AXIS2_CALL
    00157     axutil_log_impl_log_warning(
    00158         axutil_log_t * log,
    00159         const axis2_char_t * filename,
    00160         const int linenumber,
    00161         const axis2_char_t * format,
    00162         ...);
    00163
    00164     AXIS2_EXTERN void AXIS2_CALL
    00165     axutil_log_impl_log_info(
    00166         axutil_log_t * log,
    00167         const axis2_char_t * format,
    00168         ...);
    00169
    00170     AXIS2_EXTERN void AXIS2_CALL
    00171     axutil_log_impl_log_user(
    00172         axutil_log_t * log,
    00173         const axis2_char_t * filename,
    00174         const int linenumber,
    00175         const axis2_char_t * format,
    00176         ...);
    00177
    00178     AXIS2_EXTERN void AXIS2_CALL
    00179     axutil_log_impl_log_debug(
    00180         axutil_log_t * log,
    00181         const axis2_char_t * filename,
    00182         const int linenumber,
    00183         const axis2_char_t * format,
    00184         ...);
    00185
    00186     AXIS2_EXTERN void AXIS2_CALL
    00187     axutil_log_impl_log_trace(
    00188         axutil_log_t * log,
    00189         const axis2_char_t * filename,
    00190         const int linenumber,
    00191         const axis2_char_t * format,
    00192         ...);
    00193
    00194     AXIS2_EXTERN void AXIS2_CALL
    00195     axutil_log_free(
    00196         axutil_allocator_t * allocator,
    00197         struct axutil_log *log);
    00198
    00199     AXIS2_EXTERN void AXIS2_CALL
    00200     axutil_log_write(
    00201         axutil_log_t * log,
    00202         const axis2_char_t * buffer,
    00203         axutil_log_levels_t level,
    00204         const axis2_char_t * file,
    00205         const int line);
    00206
    00207
    00208 #define AXIS2_LOG_FREE(allocator, log) \
    00209       axutil_log_free(allocator, log)
    00210
    00211 #define AXIS2_LOG_WRITE(log, buffer, level, file) \
    00212       axutil_log_write(log, buffer, level, file, AXIS2_LOG_SI)
    00213
    00214 #define AXIS2_LOG_USER axutil_log_impl_log_user
    00215 #define AXIS2_LOG_DEBUG axutil_log_impl_log_debug
    00216 #define AXIS2_LOG_INFO axutil_log_impl_log_info
    00217 #define AXIS2_LOG_WARNING axutil_log_impl_log_warning
    00218 #define AXIS2_LOG_ERROR axutil_log_impl_log_error
    00219 #define AXIS2_LOG_CRITICAL axutil_log_impl_log_critical
    00220
    00221 #ifdef AXIS2_TRACE
    00222 #define AXIS2_LOG_TRACE axutil_log_impl_log_trace
    00223 #else
    00224 # ifdef HAVE_GNUC_VARARGS
    00225 #  define AXIS2_LOG_TRACE(params, args ...)
    00226 # elif defined HAVE_ISO_VARARGS
    00227 #  define AXIS2_LOG_TRACE(params, ...)
    00228 # elif __STDC__ && __STDC_VERSION > 199901L
    00229 #  define AXIS2_LOG_TRACE(params, ...)
    00230 # elif WIN32
    00231 #  define AXIS2_LOG_TRACE axutil_log_impl_log_trace
    00232 # else
    00233 #  define AXIS2_LOG_TRACE axutil_log_impl_log_trace
    00234 # endif
    00235 #endif
    00236
    00237 #ifndef AXIS2_LOG_PROJECT_PREFIX
    00238
    00239 #define AXIS2_LOG_PROJECT_PREFIX "[axis2c]"
    00240 #endif
    00241
    00242 #define AXIS2_LOG_USER_MSG(log, msg) AXIS2_LOG_USER (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg)
    00243 #define AXIS2_LOG_DEBUG_MSG(log, msg) AXIS2_LOG_DEBUG (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg)
    00244 #define AXIS2_LOG_INFO_MSG(log, msg) AXIS2_LOG_INFO (log, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg)
    00245 #define AXIS2_LOG_WARNING_MSG(log, msg) AXIS2_LOG_WARNING (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg)
    00246 #define AXIS2_LOG_ERROR_MSG(log, msg) AXIS2_LOG_ERROR (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg)
    00247 #define AXIS2_LOG_CRITICAL_MSG(log, msg) AXIS2_LOG_CRITICAL (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg)
    00248 #define AXIS2_LOG_TRACE_MSG(log, msg) AXIS2_LOG_TRACE (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg)
    00249
    00250
    00251 #define IF_AXIS2_LOG_DEBUG_ENABLED(log) if(AXIS2_LOG_LEVEL_DEBUG <= log->level && log->level != AXIS2_LOG_LEVEL_USER)
    00252
    00255 #ifdef __cplusplus
    00256 }
    00257 #endif
    00258
    00259 #endif                          /* AXIS2_LOG_H */