• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef LOGGING_H_
6 #define LOGGING_H_
7 
8 #include <android/log.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 
12 #define CHECK_ARGS(COND, ERR)                                          \
13   "FAILED CHECK(%s) @ %s:%d (errno: %s)\n", #COND, __FILE__, __LINE__, \
14       strerror(ERR)
15 
16 #define CHECK(x)                                              \
17   do {                                                        \
18     if (!(x)) {                                               \
19       const int e = errno;                                    \
20       __android_log_print(ANDROID_LOG_FATAL, "atrace_helper", \
21                           CHECK_ARGS(x, e));                  \
22       fprintf(stderr, "\n" CHECK_ARGS(x, e));                 \
23       fflush(stderr);                                         \
24       abort();                                                \
25     }                                                         \
26   } while (0)
27 
28 #endif  // LOGGING_H_
29