• 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 // -----------------------------------------------------------------------------
16 // File: log/absl_log.h
17 // -----------------------------------------------------------------------------
18 //
19 // This header declares a family of `ABSL_LOG` macros as alternative spellings
20 // for macros in `log.h`.
21 //
22 // Basic invocation looks like this:
23 //
24 //   ABSL_LOG(INFO) << "Found " << num_cookies << " cookies";
25 //
26 // Most `ABSL_LOG` macros take a severity level argument. The severity levels
27 // are `INFO`, `WARNING`, `ERROR`, and `FATAL`.
28 //
29 // For full documentation, see comments in `log.h`, which includes full
30 // reference documentation on use of the equivalent `LOG` macro and has an
31 // identical set of macros without the ABSL_* prefix.
32 
33 #ifndef ABSL_LOG_ABSL_LOG_H_
34 #define ABSL_LOG_ABSL_LOG_H_
35 
36 #include "absl/log/internal/log_impl.h"
37 
38 #define ABSL_LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
39 #define ABSL_PLOG(severity) ABSL_LOG_INTERNAL_PLOG_IMPL(_##severity)
40 #define ABSL_DLOG(severity) ABSL_LOG_INTERNAL_DLOG_IMPL(_##severity)
41 
42 #define ABSL_LOG_IF(severity, condition) \
43   ABSL_LOG_INTERNAL_LOG_IF_IMPL(_##severity, condition)
44 #define ABSL_PLOG_IF(severity, condition) \
45   ABSL_LOG_INTERNAL_PLOG_IF_IMPL(_##severity, condition)
46 #define ABSL_DLOG_IF(severity, condition) \
47   ABSL_LOG_INTERNAL_DLOG_IF_IMPL(_##severity, condition)
48 
49 #define ABSL_LOG_EVERY_N(severity, n) \
50   ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(_##severity, n)
51 #define ABSL_LOG_FIRST_N(severity, n) \
52   ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(_##severity, n)
53 #define ABSL_LOG_EVERY_POW_2(severity) \
54   ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(_##severity)
55 #define ABSL_LOG_EVERY_N_SEC(severity, n_seconds) \
56   ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
57 
58 #define ABSL_PLOG_EVERY_N(severity, n) \
59   ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(_##severity, n)
60 #define ABSL_PLOG_FIRST_N(severity, n) \
61   ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(_##severity, n)
62 #define ABSL_PLOG_EVERY_POW_2(severity) \
63   ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(_##severity)
64 #define ABSL_PLOG_EVERY_N_SEC(severity, n_seconds) \
65   ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
66 
67 #define ABSL_DLOG_EVERY_N(severity, n) \
68   ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(_##severity, n)
69 #define ABSL_DLOG_FIRST_N(severity, n) \
70   ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(_##severity, n)
71 #define ABSL_DLOG_EVERY_POW_2(severity) \
72   ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(_##severity)
73 #define ABSL_DLOG_EVERY_N_SEC(severity, n_seconds) \
74   ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
75 
76 #define ABSL_LOG_IF_EVERY_N(severity, condition, n) \
77   ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n)
78 #define ABSL_LOG_IF_FIRST_N(severity, condition, n) \
79   ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n)
80 #define ABSL_LOG_IF_EVERY_POW_2(severity, condition) \
81   ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
82 #define ABSL_LOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
83   ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
84 
85 #define ABSL_PLOG_IF_EVERY_N(severity, condition, n) \
86   ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
87 #define ABSL_PLOG_IF_FIRST_N(severity, condition, n) \
88   ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
89 #define ABSL_PLOG_IF_EVERY_POW_2(severity, condition) \
90   ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
91 #define ABSL_PLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
92   ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
93 
94 #define ABSL_DLOG_IF_EVERY_N(severity, condition, n) \
95   ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
96 #define ABSL_DLOG_IF_FIRST_N(severity, condition, n) \
97   ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
98 #define ABSL_DLOG_IF_EVERY_POW_2(severity, condition) \
99   ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
100 #define ABSL_DLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
101   ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
102 
103 #endif  // ABSL_LOG_ABSL_LOG_H_
104