OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Logging macros, similar to Chromium's base/logging.h, except with |MOJO_| | 5 // Logging macros, similar to Chromium's base/logging.h, except with |MOJO_| |
6 // prefixes and missing some features (notably |CHECK_EQ()|, etc.). | 6 // prefixes and missing some features (notably |CHECK_EQ()|, etc.). |
7 | 7 |
8 // TODO(vtl): It's weird that this is in the environment directory, since its | 8 // TODO(vtl): It's weird that this is in the environment directory, since its |
9 // implementation (in environment/lib) is meant to be used by any implementation | 9 // implementation (in environment/lib) is meant to be used by any implementation |
10 // of the environment. | 10 // of the environment. |
11 | 11 |
12 #ifndef THIRD_PARTY_MOJO_SRC_MOJO_PUBLIC_CPP_ENVIRONMENT_LOGGING_H_ | 12 #ifndef MOJO_PUBLIC_CPP_ENVIRONMENT_LOGGING_H_ |
13 #define THIRD_PARTY_MOJO_SRC_MOJO_PUBLIC_CPP_ENVIRONMENT_LOGGING_H_ | 13 #define MOJO_PUBLIC_CPP_ENVIRONMENT_LOGGING_H_ |
14 | 14 |
15 #include <sstream> | 15 #include <sstream> |
16 | 16 |
17 #include "third_party/mojo/src/mojo/public/c/environment/logger.h" | 17 #include "mojo/public/c/environment/logger.h" |
18 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h" | 18 #include "mojo/public/cpp/environment/environment.h" |
19 #include "third_party/mojo/src/mojo/public/cpp/system/macros.h" | 19 #include "mojo/public/cpp/system/macros.h" |
20 | 20 |
21 #define MOJO_LOG_STREAM(level) \ | 21 #define MOJO_LOG_STREAM(level) \ |
22 ::mojo::internal::LogMessage(MOJO_LOG_LEVEL_##level, __FILE__, __LINE__) \ | 22 ::mojo::internal::LogMessage(MOJO_LOG_LEVEL_##level, __FILE__, __LINE__) \ |
23 .stream() | 23 .stream() |
24 | 24 |
25 #define MOJO_LAZY_LOG_STREAM(level, condition) \ | 25 #define MOJO_LAZY_LOG_STREAM(level, condition) \ |
26 !(condition) ? (void)0 \ | 26 !(condition) ? (void)0 \ |
27 : ::mojo::internal::VoidifyOstream() & MOJO_LOG_STREAM(level) | 27 : ::mojo::internal::VoidifyOstream() & MOJO_LOG_STREAM(level) |
28 | 28 |
29 #define MOJO_SHOULD_LOG(level) \ | 29 #define MOJO_SHOULD_LOG(level) \ |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 // Used to ignore a stream. | 81 // Used to ignore a stream. |
82 struct VoidifyOstream { | 82 struct VoidifyOstream { |
83 // Use & since it has precedence lower than << but higher than ?:. | 83 // Use & since it has precedence lower than << but higher than ?:. |
84 void operator&(std::ostream&) {} | 84 void operator&(std::ostream&) {} |
85 }; | 85 }; |
86 | 86 |
87 } // namespace internal | 87 } // namespace internal |
88 } // namespace mojo | 88 } // namespace mojo |
89 | 89 |
90 #endif // THIRD_PARTY_MOJO_SRC_MOJO_PUBLIC_CPP_ENVIRONMENT_LOGGING_H_ | 90 #endif // MOJO_PUBLIC_CPP_ENVIRONMENT_LOGGING_H_ |
OLD | NEW |