• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 The Abseil Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef ABSL_LOG_INTERNAL_LOG_IMPL_H_
16 #define ABSL_LOG_INTERNAL_LOG_IMPL_H_
17 
18 #include "absl/log/internal/conditions.h"
19 #include "absl/log/internal/log_message.h"
20 #include "absl/log/internal/strip.h"
21 
22 // ABSL_LOG()
23 #define ABSL_LOG_INTERNAL_LOG_IMPL(severity)             \
24   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
25       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
26 
27 // ABSL_PLOG()
28 #define ABSL_LOG_INTERNAL_PLOG_IMPL(severity)              \
29   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true)   \
30       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
31           .WithPerror()
32 
33 // ABSL_DLOG()
34 #ifndef NDEBUG
35 #define ABSL_LOG_INTERNAL_DLOG_IMPL(severity)            \
36   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
37       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
38 #else
39 #define ABSL_LOG_INTERNAL_DLOG_IMPL(severity)             \
40   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, false) \
41       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
42 #endif
43 
44 #define ABSL_LOG_INTERNAL_LOG_IF_IMPL(severity, condition)    \
45   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \
46       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
47 #define ABSL_LOG_INTERNAL_PLOG_IF_IMPL(severity, condition)   \
48   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \
49       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()    \
50           .WithPerror()
51 
52 #ifndef NDEBUG
53 #define ABSL_LOG_INTERNAL_DLOG_IF_IMPL(severity, condition)   \
54   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \
55       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
56 #else
57 #define ABSL_LOG_INTERNAL_DLOG_IF_IMPL(severity, condition)              \
58   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, false && (condition)) \
59       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
60 #endif
61 
62 // ABSL_LOG_EVERY_N
63 #define ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(severity, n)            \
64   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryN, n) \
65       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
66 
67 // ABSL_LOG_FIRST_N
68 #define ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(severity, n)            \
69   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(FirstN, n) \
70       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
71 
72 // ABSL_LOG_EVERY_POW_2
73 #define ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(severity)           \
74   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryPow2) \
75       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
76 
77 // ABSL_LOG_EVERY_N_SEC
78 #define ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(severity, n_seconds)           \
79   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryNSec, n_seconds) \
80       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
81 
82 #define ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(severity, n)           \
83   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryN, n) \
84       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()         \
85           .WithPerror()
86 
87 #define ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(severity, n)           \
88   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(FirstN, n) \
89       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()         \
90           .WithPerror()
91 
92 #define ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(severity)          \
93   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryPow2) \
94       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()         \
95           .WithPerror()
96 
97 #define ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(severity, n_seconds)          \
98   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryNSec, n_seconds) \
99       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()                    \
100           .WithPerror()
101 
102 #ifndef NDEBUG
103 #define ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(severity, n) \
104   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true)       \
105   (EveryN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
106 
107 #define ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(severity, n) \
108   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true)       \
109   (FirstN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
110 
111 #define ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(severity) \
112   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true)        \
113   (EveryPow2) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
114 
115 #define ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \
116   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true)                   \
117   (EveryNSec, n_seconds) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
118 
119 #else  // def NDEBUG
120 #define ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(severity, n) \
121   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false)      \
122   (EveryN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
123 
124 #define ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(severity, n) \
125   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false)      \
126   (FirstN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
127 
128 #define ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(severity) \
129   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false)       \
130   (EveryPow2) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
131 
132 #define ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \
133   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false)                  \
134   (EveryNSec, n_seconds) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
135 #endif  // def NDEBUG
136 
137 #define ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(severity, condition, n)   \
138   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \
139       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
140 
141 #define ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(severity, condition, n)   \
142   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \
143       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
144 
145 #define ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(severity, condition)  \
146   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \
147       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
148 
149 #define ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(severity, condition,  \
150                                                   n_seconds)            \
151   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \
152                                                              n_seconds) \
153       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
154 
155 #define ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(severity, condition, n)  \
156   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \
157       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()              \
158           .WithPerror()
159 
160 #define ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(severity, condition, n)  \
161   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \
162       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()              \
163           .WithPerror()
164 
165 #define ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(severity, condition) \
166   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \
167       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()              \
168           .WithPerror()
169 
170 #define ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(severity, condition, \
171                                                    n_seconds)           \
172   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \
173                                                              n_seconds) \
174       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()              \
175           .WithPerror()
176 
177 #ifndef NDEBUG
178 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(severity, condition, n)  \
179   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \
180       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
181 
182 #define ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(severity, condition, n)  \
183   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \
184       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
185 
186 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(severity, condition) \
187   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \
188       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
189 
190 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(severity, condition, \
191                                                    n_seconds)           \
192   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \
193                                                              n_seconds) \
194       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
195 
196 #else  // def NDEBUG
197 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(severity, condition, n)   \
198   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
199       EveryN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
200 
201 #define ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(severity, condition, n)   \
202   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
203       FirstN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
204 
205 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(severity, condition)  \
206   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
207       EveryPow2) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
208 
209 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(severity, condition,  \
210                                                    n_seconds)            \
211   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
212       EveryNSec, n_seconds)                                              \
213       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
214 #endif  // def NDEBUG
215 
216 #endif  // ABSL_LOG_INTERNAL_LOG_IMPL_H_
217