| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_LOGGING_H_ | 5 #ifndef BASE_LOGGING_H_ |
| 6 #define BASE_LOGGING_H_ | 6 #define BASE_LOGGING_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <cassert> | 10 #include <cassert> |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 protected: | 800 protected: |
| 801 unsigned long last_error_; | 801 unsigned long last_error_; |
| 802 }; | 802 }; |
| 803 | 803 |
| 804 SaveLastError last_error_; | 804 SaveLastError last_error_; |
| 805 #endif | 805 #endif |
| 806 | 806 |
| 807 DISALLOW_COPY_AND_ASSIGN(LogMessage); | 807 DISALLOW_COPY_AND_ASSIGN(LogMessage); |
| 808 }; | 808 }; |
| 809 | 809 |
| 810 // A non-macro interface to the log facility; (useful | |
| 811 // when the logging level is not a compile-time constant). | |
| 812 inline void LogAtLevel(int log_level, const std::string& msg) { | |
| 813 LogMessage(__FILE__, __LINE__, log_level).stream() << msg; | |
| 814 } | |
| 815 | |
| 816 // This class is used to explicitly ignore values in the conditional | 810 // This class is used to explicitly ignore values in the conditional |
| 817 // logging macros. This avoids compiler warnings like "value computed | 811 // logging macros. This avoids compiler warnings like "value computed |
| 818 // is not used" and "statement has no effect". | 812 // is not used" and "statement has no effect". |
| 819 class LogMessageVoidify { | 813 class LogMessageVoidify { |
| 820 public: | 814 public: |
| 821 LogMessageVoidify() { } | 815 LogMessageVoidify() { } |
| 822 // This has to be an operator with a precedence lower than << but | 816 // This has to be an operator with a precedence lower than << but |
| 823 // higher than ?: | 817 // higher than ?: |
| 824 void operator&(std::ostream&) { } | 818 void operator&(std::ostream&) { } |
| 825 }; | 819 }; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 #elif NOTIMPLEMENTED_POLICY == 5 | 961 #elif NOTIMPLEMENTED_POLICY == 5 |
| 968 #define NOTIMPLEMENTED() do {\ | 962 #define NOTIMPLEMENTED() do {\ |
| 969 static bool logged_once = false;\ | 963 static bool logged_once = false;\ |
| 970 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 964 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 971 logged_once = true;\ | 965 logged_once = true;\ |
| 972 } while(0);\ | 966 } while(0);\ |
| 973 EAT_STREAM_PARAMETERS | 967 EAT_STREAM_PARAMETERS |
| 974 #endif | 968 #endif |
| 975 | 969 |
| 976 #endif // BASE_LOGGING_H_ | 970 #endif // BASE_LOGGING_H_ |
| OLD | NEW |