| 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 MOJO_PUBLIC_CPP_ENVIRONMENT_LOGGING_H_ |  12 #ifndef MOJO_PUBLIC_CPP_ENVIRONMENT_LOGGING_H_ | 
|  13 #define 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 "mojo/public/c/environment/logger.h" |  17 #include "mojo/public/c/environment/logger.h" | 
|  18 #include "mojo/public/cpp/environment/environment.h" |  18 #include "mojo/public/cpp/environment/environment.h" | 
|  19 #include "mojo/public/cpp/system/macros.h" |  19 #include "mojo/public/cpp/system/macros.h" | 
|  20  |  20  | 
 |  21 #if defined(OS_WIN) | 
 |  22 // To avoid a compile failure on Windows because it defines ERROR, which is also | 
 |  23 // used by the logs. Similar to change in base/logging.h. | 
 |  24 #undef ERROR | 
 |  25 #endif | 
 |  26  | 
|  21 #define MOJO_LOG_STREAM(level)                                             \ |  27 #define MOJO_LOG_STREAM(level)                                             \ | 
|  22   ::mojo::internal::LogMessage(MOJO_LOG_LEVEL_##level, __FILE__, __LINE__) \ |  28   ::mojo::internal::LogMessage(MOJO_LOG_LEVEL_##level, __FILE__, __LINE__) \ | 
|  23       .stream() |  29       .stream() | 
|  24  |  30  | 
|  25 #define MOJO_LAZY_LOG_STREAM(level, condition) \ |  31 #define MOJO_LAZY_LOG_STREAM(level, condition) \ | 
|  26   !(condition) ? (void)0                       \ |  32   !(condition) ? (void)0                       \ | 
|  27                : ::mojo::internal::VoidifyOstream() & MOJO_LOG_STREAM(level) |  33                : ::mojo::internal::VoidifyOstream() & MOJO_LOG_STREAM(level) | 
|  28  |  34  | 
|  29 #define MOJO_SHOULD_LOG(level) \ |  35 #define MOJO_SHOULD_LOG(level) \ | 
|  30   (MOJO_LOG_LEVEL_##level >=   \ |  36   (MOJO_LOG_LEVEL_##level >=   \ | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  81 // Used to ignore a stream. |  87 // Used to ignore a stream. | 
|  82 struct VoidifyOstream { |  88 struct VoidifyOstream { | 
|  83   // Use & since it has precedence lower than << but higher than ?:. |  89   // Use & since it has precedence lower than << but higher than ?:. | 
|  84   void operator&(std::ostream&) {} |  90   void operator&(std::ostream&) {} | 
|  85 }; |  91 }; | 
|  86  |  92  | 
|  87 }  // namespace internal |  93 }  // namespace internal | 
|  88 }  // namespace mojo |  94 }  // namespace mojo | 
|  89  |  95  | 
|  90 #endif  // MOJO_PUBLIC_CPP_ENVIRONMENT_LOGGING_H_ |  96 #endif  // MOJO_PUBLIC_CPP_ENVIRONMENT_LOGGING_H_ | 
| OLD | NEW |