admin
2023-03-07 8b06b1cbf112d55307ea8a6efe711db4e7506d89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
#ifndef MINI_CHROMIUM_BASE_FUCHSIA_FUCHSIA_LOGGING_H_
#define MINI_CHROMIUM_BASE_FUCHSIA_FUCHSIA_LOGGING_H_
 
#include <zircon/types.h>
 
#include "base/logging.h"
#include "base/macros.h"
 
// Use the ZX_LOG family of macros along with a zx_status_t containing a Zircon
// error. The error value will be decoded so that logged messages explain the
// error.
 
namespace logging {
 
class ZxLogMessage : public logging::LogMessage {
 public:
  ZxLogMessage(const char* function,
               const char* file_path,
               int line,
               LogSeverity severity,
               zx_status_t zx_err);
  ~ZxLogMessage();
 
 private:
  zx_status_t zx_err_;
 
  DISALLOW_COPY_AND_ASSIGN(ZxLogMessage);
};
 
}  // namespace logging
 
#define ZX_LOG_STREAM(severity, zx_err) \
  COMPACT_GOOGLE_LOG_EX_##severity(ZxLogMessage, zx_err).stream()
 
#define ZX_LOG(severity, zx_err) \
  LAZY_STREAM(ZX_LOG_STREAM(severity, zx_err), LOG_IS_ON(severity))
#define ZX_LOG_IF(severity, condition, zx_err) \
  LAZY_STREAM(ZX_LOG_STREAM(severity, zx_err), \
              LOG_IS_ON(severity) && (condition))
 
#define ZX_CHECK(condition, zx_err)                       \
  LAZY_STREAM(ZX_LOG_STREAM(FATAL, zx_err), !(condition)) \
      << "Check failed: " #condition << ". "
 
#define ZX_DLOG(severity, zx_err) \
  LAZY_STREAM(ZX_LOG_STREAM(severity, zx_err), DLOG_IS_ON(severity))
#define ZX_DLOG_IF(severity, condition, zx_err) \
  LAZY_STREAM(ZX_LOG_STREAM(severity, zx_err),  \
              DLOG_IS_ON(severity) && (condition))
 
#define ZX_DCHECK(condition, zx_err)                                        \
  LAZY_STREAM(ZX_LOG_STREAM(FATAL, zx_err), DCHECK_IS_ON() && !(condition)) \
      << "Check failed: " #condition << ". "
 
#endif  // MINI_CHROMIUM_BASE_FUCHSIA_FUCHSIA_LOGGING_H_