| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 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 // http://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 #ifndef CRASHPAD_UTIL_WIN_NTSTATUS_LOGGING_H_ |
| 16 #define CRASHPAD_UTIL_WIN_NTSTATUS_LOGGING_H_ |
| 17 |
| 18 #include <windows.h> |
| 19 |
| 20 #include "base/basictypes.h" |
| 21 #include "base/logging.h" |
| 22 |
| 23 namespace logging { |
| 24 |
| 25 class NtstatusLogMessage : public logging::LogMessage { |
| 26 public: |
| 27 NtstatusLogMessage( |
| 28 #if defined(MINI_CHROMIUM_BASE_LOGGING_H_) |
| 29 const char* function, |
| 30 #endif |
| 31 const char* file_path, |
| 32 int line, |
| 33 LogSeverity severity, |
| 34 DWORD ntstatus); |
| 35 ~NtstatusLogMessage(); |
| 36 |
| 37 private: |
| 38 DWORD ntstatus_; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(NtstatusLogMessage); |
| 41 }; |
| 42 |
| 43 } // namespace logging |
| 44 |
| 45 #define NTSTATUS_LOG_STREAM(severity, ntstatus) \ |
| 46 COMPACT_GOOGLE_LOG_EX_##severity(NtstatusLogMessage, ntstatus).stream() |
| 47 |
| 48 #if defined(MINI_CHROMIUM_BASE_LOGGING_H_) |
| 49 |
| 50 #define NTSTATUS_VLOG_STREAM(verbose_level, ntstatus) \ |
| 51 logging::NtstatusLogMessage( \ |
| 52 __PRETTY_FUNCTION__, __FILE__, __LINE__, -verbose_level, ntstatus) \ |
| 53 .stream() |
| 54 |
| 55 #else |
| 56 |
| 57 #define NTSTATUS_VLOG_STREAM(verbose_level, ntstatus) \ |
| 58 logging::NtstatusLogMessage(__FILE__, __LINE__, -verbose_level, ntstatus) \ |
| 59 .stream() |
| 60 |
| 61 #endif // MINI_CHROMIUM_BASE_LOGGING_H_ |
| 62 |
| 63 #define NTSTATUS_LOG(severity, ntstatus) \ |
| 64 LAZY_STREAM(NTSTATUS_LOG_STREAM(severity, ntstatus), LOG_IS_ON(severity)) |
| 65 #define NTSTATUS_LOG_IF(severity, condition, ntstatus) \ |
| 66 LAZY_STREAM(NTSTATUS_LOG_STREAM(severity, ntstatus), \ |
| 67 LOG_IS_ON(severity) && (condition)) |
| 68 |
| 69 #define NTSTATUS_VLOG(verbose_level, ntstatus) \ |
| 70 LAZY_STREAM(NTSTATUS_VLOG_STREAM(verbose_level, ntstatus), \ |
| 71 VLOG_IS_ON(verbose_level)) |
| 72 #define NTSTATUS_VLOG_IF(verbose_level, condition, ntstatus) \ |
| 73 LAZY_STREAM(NTSTATUS_VLOG_STREAM(verbose_level, ntstatus), \ |
| 74 VLOG_IS_ON(verbose_level) && (condition)) |
| 75 |
| 76 #define NTSTATUS_CHECK(condition, ntstatus) \ |
| 77 LAZY_STREAM(NTSTATUS_LOG_STREAM(FATAL, ntstatus), !(condition)) \ |
| 78 << "Check failed: " #condition << ". " |
| 79 |
| 80 #define NTSTATUS_DLOG(severity, ntstatus) \ |
| 81 LAZY_STREAM(NTSTATUS_LOG_STREAM(severity, ntstatus), DLOG_IS_ON(severity)) |
| 82 #define NTSTATUS_DLOG_IF(severity, condition, ntstatus) \ |
| 83 LAZY_STREAM(NTSTATUS_LOG_STREAM(severity, ntstatus), \ |
| 84 DLOG_IS_ON(severity) && (condition)) |
| 85 |
| 86 #define NTSTATUS_DVLOG(verbose_level, ntstatus) \ |
| 87 LAZY_STREAM(NTSTATUS_VLOG_STREAM(verbose_level, ntstatus), \ |
| 88 DVLOG_IS_ON(verbose_level)) |
| 89 #define NTSTATUS_DVLOG_IF(verbose_level, condition, ntstatus) \ |
| 90 LAZY_STREAM(NTSTATUS_VLOG_STREAM(verbose_level, ntstatus), \ |
| 91 DVLOG_IS_ON(verbose_level) && (condition)) |
| 92 |
| 93 #define NTSTATUS_DCHECK(condition, ntstatus) \ |
| 94 LAZY_STREAM(NTSTATUS_LOG_STREAM(FATAL, ntstatus), \ |
| 95 DCHECK_IS_ON && !(condition)) \ |
| 96 << "Check failed: " #condition << ". " |
| 97 |
| 98 #endif // CRASHPAD_UTIL_WIN_NTSTATUS_LOGGING_H_ |
| OLD | NEW |