xref: /aosp_15_r20/external/abseil-cpp/absl/log/absl_log.h (revision 9356374a3709195abf420251b3e825997ff56c0f)
1*9356374aSAndroid Build Coastguard Worker // Copyright 2022 The Abseil Authors.
2*9356374aSAndroid Build Coastguard Worker //
3*9356374aSAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*9356374aSAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*9356374aSAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*9356374aSAndroid Build Coastguard Worker //
7*9356374aSAndroid Build Coastguard Worker //      https://www.apache.org/licenses/LICENSE-2.0
8*9356374aSAndroid Build Coastguard Worker //
9*9356374aSAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*9356374aSAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*9356374aSAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*9356374aSAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*9356374aSAndroid Build Coastguard Worker // limitations under the License.
14*9356374aSAndroid Build Coastguard Worker //
15*9356374aSAndroid Build Coastguard Worker // -----------------------------------------------------------------------------
16*9356374aSAndroid Build Coastguard Worker // File: log/absl_log.h
17*9356374aSAndroid Build Coastguard Worker // -----------------------------------------------------------------------------
18*9356374aSAndroid Build Coastguard Worker //
19*9356374aSAndroid Build Coastguard Worker // This header declares a family of `ABSL_LOG` macros as alternative spellings
20*9356374aSAndroid Build Coastguard Worker // for macros in `log.h`.
21*9356374aSAndroid Build Coastguard Worker //
22*9356374aSAndroid Build Coastguard Worker // Basic invocation looks like this:
23*9356374aSAndroid Build Coastguard Worker //
24*9356374aSAndroid Build Coastguard Worker //   ABSL_LOG(INFO) << "Found " << num_cookies << " cookies";
25*9356374aSAndroid Build Coastguard Worker //
26*9356374aSAndroid Build Coastguard Worker // Most `ABSL_LOG` macros take a severity level argument. The severity levels
27*9356374aSAndroid Build Coastguard Worker // are `INFO`, `WARNING`, `ERROR`, and `FATAL`.
28*9356374aSAndroid Build Coastguard Worker //
29*9356374aSAndroid Build Coastguard Worker // For full documentation, see comments in `log.h`, which includes full
30*9356374aSAndroid Build Coastguard Worker // reference documentation on use of the equivalent `LOG` macro and has an
31*9356374aSAndroid Build Coastguard Worker // identical set of macros without the ABSL_* prefix.
32*9356374aSAndroid Build Coastguard Worker 
33*9356374aSAndroid Build Coastguard Worker #ifndef ABSL_LOG_ABSL_LOG_H_
34*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG_ABSL_LOG_H_
35*9356374aSAndroid Build Coastguard Worker 
36*9356374aSAndroid Build Coastguard Worker #include "absl/log/internal/log_impl.h"
37*9356374aSAndroid Build Coastguard Worker 
38*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
39*9356374aSAndroid Build Coastguard Worker #define ABSL_PLOG(severity) ABSL_LOG_INTERNAL_PLOG_IMPL(_##severity)
40*9356374aSAndroid Build Coastguard Worker #define ABSL_DLOG(severity) ABSL_LOG_INTERNAL_DLOG_IMPL(_##severity)
41*9356374aSAndroid Build Coastguard Worker 
42*9356374aSAndroid Build Coastguard Worker #define ABSL_VLOG(verbose_level) ABSL_LOG_INTERNAL_VLOG_IMPL(verbose_level)
43*9356374aSAndroid Build Coastguard Worker #define ABSL_DVLOG(verbose_level) ABSL_LOG_INTERNAL_DVLOG_IMPL(verbose_level)
44*9356374aSAndroid Build Coastguard Worker 
45*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG_IF(severity, condition) \
46*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_LOG_IF_IMPL(_##severity, condition)
47*9356374aSAndroid Build Coastguard Worker #define ABSL_PLOG_IF(severity, condition) \
48*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_PLOG_IF_IMPL(_##severity, condition)
49*9356374aSAndroid Build Coastguard Worker #define ABSL_DLOG_IF(severity, condition) \
50*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_DLOG_IF_IMPL(_##severity, condition)
51*9356374aSAndroid Build Coastguard Worker 
52*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG_EVERY_N(severity, n) \
53*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(_##severity, n)
54*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG_FIRST_N(severity, n) \
55*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(_##severity, n)
56*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG_EVERY_POW_2(severity) \
57*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(_##severity)
58*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG_EVERY_N_SEC(severity, n_seconds) \
59*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
60*9356374aSAndroid Build Coastguard Worker 
61*9356374aSAndroid Build Coastguard Worker #define ABSL_PLOG_EVERY_N(severity, n) \
62*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(_##severity, n)
63*9356374aSAndroid Build Coastguard Worker #define ABSL_PLOG_FIRST_N(severity, n) \
64*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(_##severity, n)
65*9356374aSAndroid Build Coastguard Worker #define ABSL_PLOG_EVERY_POW_2(severity) \
66*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(_##severity)
67*9356374aSAndroid Build Coastguard Worker #define ABSL_PLOG_EVERY_N_SEC(severity, n_seconds) \
68*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
69*9356374aSAndroid Build Coastguard Worker 
70*9356374aSAndroid Build Coastguard Worker #define ABSL_DLOG_EVERY_N(severity, n) \
71*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(_##severity, n)
72*9356374aSAndroid Build Coastguard Worker #define ABSL_DLOG_FIRST_N(severity, n) \
73*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(_##severity, n)
74*9356374aSAndroid Build Coastguard Worker #define ABSL_DLOG_EVERY_POW_2(severity) \
75*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(_##severity)
76*9356374aSAndroid Build Coastguard Worker #define ABSL_DLOG_EVERY_N_SEC(severity, n_seconds) \
77*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
78*9356374aSAndroid Build Coastguard Worker 
79*9356374aSAndroid Build Coastguard Worker #define ABSL_VLOG_EVERY_N(verbose_level, n) \
80*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_VLOG_EVERY_N_IMPL(verbose_level, n)
81*9356374aSAndroid Build Coastguard Worker #define ABSL_VLOG_FIRST_N(verbose_level, n) \
82*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_VLOG_FIRST_N_IMPL(verbose_level, n)
83*9356374aSAndroid Build Coastguard Worker #define ABSL_VLOG_EVERY_POW_2(verbose_level, n) \
84*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_VLOG_EVERY_POW_2_IMPL(verbose_level, n)
85*9356374aSAndroid Build Coastguard Worker #define ABSL_VLOG_EVERY_N_SEC(verbose_level, n) \
86*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_VLOG_EVERY_N_SEC_IMPL(verbose_level, n)
87*9356374aSAndroid Build Coastguard Worker 
88*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG_IF_EVERY_N(severity, condition, n) \
89*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n)
90*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG_IF_FIRST_N(severity, condition, n) \
91*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n)
92*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG_IF_EVERY_POW_2(severity, condition) \
93*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
94*9356374aSAndroid Build Coastguard Worker #define ABSL_LOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
95*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
96*9356374aSAndroid Build Coastguard Worker 
97*9356374aSAndroid Build Coastguard Worker #define ABSL_PLOG_IF_EVERY_N(severity, condition, n) \
98*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
99*9356374aSAndroid Build Coastguard Worker #define ABSL_PLOG_IF_FIRST_N(severity, condition, n) \
100*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
101*9356374aSAndroid Build Coastguard Worker #define ABSL_PLOG_IF_EVERY_POW_2(severity, condition) \
102*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
103*9356374aSAndroid Build Coastguard Worker #define ABSL_PLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
104*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
105*9356374aSAndroid Build Coastguard Worker 
106*9356374aSAndroid Build Coastguard Worker #define ABSL_DLOG_IF_EVERY_N(severity, condition, n) \
107*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
108*9356374aSAndroid Build Coastguard Worker #define ABSL_DLOG_IF_FIRST_N(severity, condition, n) \
109*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
110*9356374aSAndroid Build Coastguard Worker #define ABSL_DLOG_IF_EVERY_POW_2(severity, condition) \
111*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
112*9356374aSAndroid Build Coastguard Worker #define ABSL_DLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
113*9356374aSAndroid Build Coastguard Worker   ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
114*9356374aSAndroid Build Coastguard Worker 
115*9356374aSAndroid Build Coastguard Worker #endif  // ABSL_LOG_ABSL_LOG_H_
116