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/logging.h" | |
21 | |
22 namespace logging { | |
23 | |
24 class NtstatusLogMessage : public logging::LogMessage { | |
25 public: | |
26 NtstatusLogMessage(const char* function, | |
27 const char* file_path, | |
28 int line, | |
29 LogSeverity severity, | |
30 DWORD ntstatus); | |
31 ~NtstatusLogMessage(); | |
32 | |
33 private: | |
34 DWORD ntstatus_; | |
35 | |
36 DISALLOW_COPY_AND_ASSIGN(NtstatusLogMessage); | |
Mark Mentovai
2015/09/15 02:22:32
#include "base/basictypes.h".
scottmg
2015/09/15 04:33:51
Done.
| |
37 }; | |
38 | |
39 } // namespace logging | |
40 | |
41 #define NTSTATUS_LOG_STREAM(severity, ntstatus) \ | |
42 COMPACT_GOOGLE_LOG_EX_##severity(NtstatusLogMessage, ntstatus).stream() | |
43 #define NTSTATUS_VLOG_STREAM(verbose_level, ntstatus) \ | |
44 logging::NtstatusLogMessage( \ | |
45 __PRETTY_FUNCTION__, __FILE__, __LINE__, -verbose_level, ntstatus) \ | |
46 .stream() | |
47 | |
48 #define NTSTATUS_LOG(severity, ntstatus) \ | |
49 LAZY_STREAM(NTSTATUS_LOG_STREAM(severity, ntstatus), LOG_IS_ON(severity)) | |
50 #define NTSTATUS_LOG_IF(severity, condition, ntstatus) \ | |
51 LAZY_STREAM(NTSTATUS_LOG_STREAM(severity, ntstatus), \ | |
52 LOG_IS_ON(severity) && (condition)) | |
53 | |
54 #define NTSTATUS_VLOG(verbose_level, ntstatus) \ | |
55 LAZY_STREAM(NTSTATUS_VLOG_STREAM(verbose_level, ntstatus), \ | |
56 VLOG_IS_ON(verbose_level)) | |
57 #define NTSTATUS_VLOG_IF(verbose_level, condition, ntstatus) \ | |
58 LAZY_STREAM(NTSTATUS_VLOG_STREAM(verbose_level, ntstatus), \ | |
59 VLOG_IS_ON(verbose_level) && (condition)) | |
60 | |
61 #define NTSTATUS_CHECK(condition, ntstatus) \ | |
62 LAZY_STREAM(NTSTATUS_LOG_STREAM(FATAL, ntstatus), !(condition)) \ | |
63 << "Check failed: " #condition << ". " | |
64 | |
65 #define NTSTATUS_DLOG(severity, ntstatus) \ | |
66 LAZY_STREAM(NTSTATUS_LOG_STREAM(severity, ntstatus), DLOG_IS_ON(severity)) | |
67 #define NTSTATUS_DLOG_IF(severity, condition, ntstatus) \ | |
68 LAZY_STREAM(NTSTATUS_LOG_STREAM(severity, ntstatus), \ | |
69 DLOG_IS_ON(severity) && (condition)) | |
70 | |
71 #define NTSTATUS_DVLOG(verbose_level, ntstatus) \ | |
72 LAZY_STREAM(NTSTATUS_VLOG_STREAM(verbose_level, ntstatus), \ | |
73 DVLOG_IS_ON(verbose_level)) | |
74 #define NTSTATUS_DVLOG_IF(verbose_level, condition, ntstatus) \ | |
75 LAZY_STREAM(NTSTATUS_VLOG_STREAM(verbose_level, ntstatus), \ | |
76 DVLOG_IS_ON(verbose_level) && (condition)) | |
77 | |
78 #define NTSTATUS_DCHECK(condition, ntstatus) \ | |
79 LAZY_STREAM(NTSTATUS_LOG_STREAM(FATAL, ntstatus), \ | |
80 DCHECK_IS_ON && !(condition)) \ | |
81 << "Check failed: " #condition << ". " | |
82 | |
83 #endif // CRASHPAD_UTIL_WIN_NTSTATUS_LOGGING_H_ | |
OLD | NEW |