Annotation of embedaddon/nginx/src/core/ngx_log.h, revision 1.1.1.1

1.1       misho       1: 
                      2: /*
                      3:  * Copyright (C) Igor Sysoev
                      4:  * Copyright (C) Nginx, Inc.
                      5:  */
                      6: 
                      7: 
                      8: #ifndef _NGX_LOG_H_INCLUDED_
                      9: #define _NGX_LOG_H_INCLUDED_
                     10: 
                     11: 
                     12: #include <ngx_config.h>
                     13: #include <ngx_core.h>
                     14: 
                     15: 
                     16: #define NGX_LOG_STDERR            0
                     17: #define NGX_LOG_EMERG             1
                     18: #define NGX_LOG_ALERT             2
                     19: #define NGX_LOG_CRIT              3
                     20: #define NGX_LOG_ERR               4
                     21: #define NGX_LOG_WARN              5
                     22: #define NGX_LOG_NOTICE            6
                     23: #define NGX_LOG_INFO              7
                     24: #define NGX_LOG_DEBUG             8
                     25: 
                     26: #define NGX_LOG_DEBUG_CORE        0x010
                     27: #define NGX_LOG_DEBUG_ALLOC       0x020
                     28: #define NGX_LOG_DEBUG_MUTEX       0x040
                     29: #define NGX_LOG_DEBUG_EVENT       0x080
                     30: #define NGX_LOG_DEBUG_HTTP        0x100
                     31: #define NGX_LOG_DEBUG_MAIL        0x200
                     32: #define NGX_LOG_DEBUG_MYSQL       0x400
                     33: 
                     34: /*
                     35:  * do not forget to update debug_levels[] in src/core/ngx_log.c
                     36:  * after the adding a new debug level
                     37:  */
                     38: 
                     39: #define NGX_LOG_DEBUG_FIRST       NGX_LOG_DEBUG_CORE
                     40: #define NGX_LOG_DEBUG_LAST        NGX_LOG_DEBUG_MYSQL
                     41: #define NGX_LOG_DEBUG_CONNECTION  0x80000000
                     42: #define NGX_LOG_DEBUG_ALL         0x7ffffff0
                     43: 
                     44: 
                     45: typedef u_char *(*ngx_log_handler_pt) (ngx_log_t *log, u_char *buf, size_t len);
                     46: 
                     47: 
                     48: struct ngx_log_s {
                     49:     ngx_uint_t           log_level;
                     50:     ngx_open_file_t     *file;
                     51: 
                     52:     ngx_atomic_uint_t    connection;
                     53: 
                     54:     ngx_log_handler_pt   handler;
                     55:     void                *data;
                     56: 
                     57:     /*
                     58:      * we declare "action" as "char *" because the actions are usually
                     59:      * the static strings and in the "u_char *" case we have to override
                     60:      * their types all the time
                     61:      */
                     62: 
                     63:     char                *action;
                     64: };
                     65: 
                     66: 
                     67: #define NGX_MAX_ERROR_STR   2048
                     68: 
                     69: 
                     70: /*********************************/
                     71: 
                     72: #if (NGX_HAVE_C99_VARIADIC_MACROS)
                     73: 
                     74: #define NGX_HAVE_VARIADIC_MACROS  1
                     75: 
                     76: #define ngx_log_error(level, log, ...)                                        \
                     77:     if ((log)->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)
                     78: 
                     79: void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
                     80:     const char *fmt, ...);
                     81: 
                     82: #define ngx_log_debug(level, log, ...)                                        \
                     83:     if ((log)->log_level & level)                                             \
                     84:         ngx_log_error_core(NGX_LOG_DEBUG, log, __VA_ARGS__)
                     85: 
                     86: /*********************************/
                     87: 
                     88: #elif (NGX_HAVE_GCC_VARIADIC_MACROS)
                     89: 
                     90: #define NGX_HAVE_VARIADIC_MACROS  1
                     91: 
                     92: #define ngx_log_error(level, log, args...)                                    \
                     93:     if ((log)->log_level >= level) ngx_log_error_core(level, log, args)
                     94: 
                     95: void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
                     96:     const char *fmt, ...);
                     97: 
                     98: #define ngx_log_debug(level, log, args...)                                    \
                     99:     if ((log)->log_level & level)                                             \
                    100:         ngx_log_error_core(NGX_LOG_DEBUG, log, args)
                    101: 
                    102: /*********************************/
                    103: 
                    104: #else /* NO VARIADIC MACROS */
                    105: 
                    106: #define NGX_HAVE_VARIADIC_MACROS  0
                    107: 
                    108: void ngx_cdecl ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
                    109:     const char *fmt, ...);
                    110: void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
                    111:     const char *fmt, va_list args);
                    112: void ngx_cdecl ngx_log_debug_core(ngx_log_t *log, ngx_err_t err,
                    113:     const char *fmt, ...);
                    114: 
                    115: 
                    116: #endif /* VARIADIC MACROS */
                    117: 
                    118: 
                    119: /*********************************/
                    120: 
                    121: #if (NGX_DEBUG)
                    122: 
                    123: #if (NGX_HAVE_VARIADIC_MACROS)
                    124: 
                    125: #define ngx_log_debug0(level, log, err, fmt)                                  \
                    126:         ngx_log_debug(level, log, err, fmt)
                    127: 
                    128: #define ngx_log_debug1(level, log, err, fmt, arg1)                            \
                    129:         ngx_log_debug(level, log, err, fmt, arg1)
                    130: 
                    131: #define ngx_log_debug2(level, log, err, fmt, arg1, arg2)                      \
                    132:         ngx_log_debug(level, log, err, fmt, arg1, arg2)
                    133: 
                    134: #define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3)                \
                    135:         ngx_log_debug(level, log, err, fmt, arg1, arg2, arg3)
                    136: 
                    137: #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4)          \
                    138:         ngx_log_debug(level, log, err, fmt, arg1, arg2, arg3, arg4)
                    139: 
                    140: #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)    \
                    141:         ngx_log_debug(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)
                    142: 
                    143: #define ngx_log_debug6(level, log, err, fmt,                                  \
                    144:                        arg1, arg2, arg3, arg4, arg5, arg6)                    \
                    145:         ngx_log_debug(level, log, err, fmt,                                   \
                    146:                        arg1, arg2, arg3, arg4, arg5, arg6)
                    147: 
                    148: #define ngx_log_debug7(level, log, err, fmt,                                  \
                    149:                        arg1, arg2, arg3, arg4, arg5, arg6, arg7)              \
                    150:         ngx_log_debug(level, log, err, fmt,                                   \
                    151:                        arg1, arg2, arg3, arg4, arg5, arg6, arg7)
                    152: 
                    153: #define ngx_log_debug8(level, log, err, fmt,                                  \
                    154:                        arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)        \
                    155:         ngx_log_debug(level, log, err, fmt,                                   \
                    156:                        arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
                    157: 
                    158: 
                    159: #else /* NO VARIADIC MACROS */
                    160: 
                    161: #define ngx_log_debug0(level, log, err, fmt)                                  \
                    162:     if ((log)->log_level & level)                                             \
                    163:         ngx_log_debug_core(log, err, fmt)
                    164: 
                    165: #define ngx_log_debug1(level, log, err, fmt, arg1)                            \
                    166:     if ((log)->log_level & level)                                             \
                    167:         ngx_log_debug_core(log, err, fmt, arg1)
                    168: 
                    169: #define ngx_log_debug2(level, log, err, fmt, arg1, arg2)                      \
                    170:     if ((log)->log_level & level)                                             \
                    171:         ngx_log_debug_core(log, err, fmt, arg1, arg2)
                    172: 
                    173: #define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3)                \
                    174:     if ((log)->log_level & level)                                             \
                    175:         ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3)
                    176: 
                    177: #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4)          \
                    178:     if ((log)->log_level & level)                                             \
                    179:         ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4)
                    180: 
                    181: #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)    \
                    182:     if ((log)->log_level & level)                                             \
                    183:         ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5)
                    184: 
                    185: #define ngx_log_debug6(level, log, err, fmt,                                  \
                    186:                        arg1, arg2, arg3, arg4, arg5, arg6)                    \
                    187:     if ((log)->log_level & level)                                             \
                    188:         ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
                    189: 
                    190: #define ngx_log_debug7(level, log, err, fmt,                                  \
                    191:                        arg1, arg2, arg3, arg4, arg5, arg6, arg7)              \
                    192:     if ((log)->log_level & level)                                             \
                    193:         ngx_log_debug_core(log, err, fmt,                                     \
                    194:                        arg1, arg2, arg3, arg4, arg5, arg6, arg7)
                    195: 
                    196: #define ngx_log_debug8(level, log, err, fmt,                                  \
                    197:                        arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)        \
                    198:     if ((log)->log_level & level)                                             \
                    199:         ngx_log_debug_core(log, err, fmt,                                     \
                    200:                        arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
                    201: 
                    202: #endif
                    203: 
                    204: #else /* NO NGX_DEBUG */
                    205: 
                    206: #define ngx_log_debug0(level, log, err, fmt)
                    207: #define ngx_log_debug1(level, log, err, fmt, arg1)
                    208: #define ngx_log_debug2(level, log, err, fmt, arg1, arg2)
                    209: #define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3)
                    210: #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4)
                    211: #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)
                    212: #define ngx_log_debug6(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
                    213: #define ngx_log_debug7(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5,    \
                    214:                        arg6, arg7)
                    215: #define ngx_log_debug8(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5,    \
                    216:                        arg6, arg7, arg8)
                    217: 
                    218: #endif
                    219: 
                    220: /*********************************/
                    221: 
                    222: ngx_log_t *ngx_log_init(u_char *prefix);
                    223: ngx_log_t *ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name);
                    224: char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log);
                    225: void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...);
                    226: void ngx_cdecl ngx_log_stderr(ngx_err_t err, const char *fmt, ...);
                    227: u_char *ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err);
                    228: 
                    229: 
                    230: /*
                    231:  * ngx_write_stderr() cannot be implemented as macro, since
                    232:  * MSVC does not allow to use #ifdef inside macro parameters.
                    233:  *
                    234:  * ngx_write_fd() is used instead of ngx_write_console(), since
                    235:  * CharToOemBuff() inside ngx_write_console() cannot be used with
                    236:  * read only buffer as destination and CharToOemBuff() is not needed
                    237:  * for ngx_write_stderr() anyway.
                    238:  */
                    239: static ngx_inline void
                    240: ngx_write_stderr(char *text)
                    241: {
                    242:     (void) ngx_write_fd(ngx_stderr, text, strlen(text));
                    243: }
                    244: 
                    245: 
                    246: extern ngx_module_t  ngx_errlog_module;
                    247: extern ngx_uint_t    ngx_use_stderr;
                    248: 
                    249: 
                    250: #endif /* _NGX_LOG_H_INCLUDED_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>