xref: /aosp_15_r20/external/puffin/src/logging.h (revision 07fb1d065b7cfb4729786fadd42a612532d2f466)
1*07fb1d06SElliott Hughes // Copyright 2017 The ChromiumOS Authors
2*07fb1d06SElliott Hughes // Use of this source code is governed by a BSD-style license that can be
3*07fb1d06SElliott Hughes // found in the LICENSE file.
4*07fb1d06SElliott Hughes 
5*07fb1d06SElliott Hughes #ifndef SRC_LOGGING_H_
6*07fb1d06SElliott Hughes #define SRC_LOGGING_H_
7*07fb1d06SElliott Hughes 
8*07fb1d06SElliott Hughes #if defined(BASE_VER) && BASE_VER >= 822064
9*07fb1d06SElliott Hughes #include "base/check.h"  // CHECK-related macros are defined in base/check.h on Chrome OS.
10*07fb1d06SElliott Hughes #include "base/logging.h"
11*07fb1d06SElliott Hughes #elif USE_BRILLO
12*07fb1d06SElliott Hughes #include "base/logging.h"
13*07fb1d06SElliott Hughes #else
14*07fb1d06SElliott Hughes #include "glog/logging.h"
15*07fb1d06SElliott Hughes #endif
16*07fb1d06SElliott Hughes 
17*07fb1d06SElliott Hughes #define TEST_AND_RETURN_FALSE(_x)   \
18*07fb1d06SElliott Hughes   do {                              \
19*07fb1d06SElliott Hughes     if (!(_x)) {                    \
20*07fb1d06SElliott Hughes       LOG(ERROR) << #_x " failed."; \
21*07fb1d06SElliott Hughes       return false;                 \
22*07fb1d06SElliott Hughes     }                               \
23*07fb1d06SElliott Hughes   } while (0)
24*07fb1d06SElliott Hughes 
25*07fb1d06SElliott Hughes #define TEST_AND_RETURN_VALUE(_x, _v) \
26*07fb1d06SElliott Hughes   do {                                \
27*07fb1d06SElliott Hughes     if (!(_x)) {                      \
28*07fb1d06SElliott Hughes       LOG(ERROR) << #_x " failed.";   \
29*07fb1d06SElliott Hughes       return (_v);                    \
30*07fb1d06SElliott Hughes     }                                 \
31*07fb1d06SElliott Hughes   } while (0)
32*07fb1d06SElliott Hughes 
33*07fb1d06SElliott Hughes #endif  // SRC_LOGGING_H_
34