xref: /unit/src/nxt_thread_log.h (revision 0:a63ceefd6ab0)
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) NGINX, Inc.
5  */
6 
7 #ifndef _NXT_THREAD_LOG_H_INCLUDED_
8 #define _NXT_THREAD_LOG_H_INCLUDED_
9 
10 
11 #define nxt_thread_log_emerg(...)                                             \
12     do {                                                                      \
13         nxt_thread_t  *_thr = nxt_thread();                                   \
14                                                                               \
15         nxt_log_emerg(_thr->log, __VA_ARGS__);                                \
16                                                                               \
17     } while (0)
18 
19 
20 #define nxt_thread_log_alert(...)                                             \
21     do {                                                                      \
22         nxt_thread_t  *_thr = nxt_thread();                                   \
23                                                                               \
24         nxt_log_alert(_thr->log, __VA_ARGS__);                                \
25                                                                               \
26     } while (0)
27 
28 
29 #define nxt_thread_log_error(_level, ...)                                     \
30     do {                                                                      \
31         nxt_thread_t  *_thr = nxt_thread();                                   \
32                                                                               \
33         nxt_log_error(_level, _thr->log, __VA_ARGS__);                        \
34                                                                               \
35     } while (0)
36 
37 
38 #if (NXT_DEBUG)
39 
40 #define nxt_thread_log_debug(...)                                             \
41     do {                                                                      \
42         nxt_thread_t  *_thr = nxt_thread();                                   \
43                                                                               \
44         nxt_log_debug(_thr->log, __VA_ARGS__);                                \
45                                                                               \
46     } while (0)
47 
48 
49 #define nxt_thread_debug(thr)                                                 \
50     nxt_thread_t  *thr = nxt_thread()
51 
52 #else
53 
54 #define nxt_thread_log_debug(...)
55 #define nxt_thread_debug(thr)
56 
57 #endif
58 
59 
60 nxt_inline nxt_log_t *
61 nxt_thread_log(void)
62 {
63     nxt_thread_t  *thr;
64 
65     thr = nxt_thread();
66     return thr->log;
67 }
68 
69 
70 #endif /* _NXT_THREAD_LOG_H_INCLUDED_ */
71