| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // use streams (it is against Google style to use streams in other places). It | 107 // use streams (it is against Google style to use streams in other places). It |
| 108 // is designed to allow you to emit non-ASCII Unicode strings to the log file, | 108 // is designed to allow you to emit non-ASCII Unicode strings to the log file, |
| 109 // which is normally ASCII. It is relatively slow, so try not to use it for | 109 // which is normally ASCII. It is relatively slow, so try not to use it for |
| 110 // common cases. Non-ASCII characters will be converted to UTF-8 by these | 110 // common cases. Non-ASCII characters will be converted to UTF-8 by these |
| 111 // operators. | 111 // operators. |
| 112 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr); | 112 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr); |
| 113 inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { | 113 inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { |
| 114 return out << wstr.c_str(); | 114 return out << wstr.c_str(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 // XXX better comment -- must be before we use << and in global namespace | |
| 118 // These functions are provided as a convenience for logging, which is where we | |
| 119 // use streams (it is against Google style to use streams in other places). It | |
| 120 // is designed to allow you to emit non-ASCII Unicode strings to the log file, | |
| 121 // which is normally ASCII. It is relatively slow, so try not to use it for | |
| 122 // common cases. Non-ASCII characters will be converted to UTF-8 by these | |
| 123 // operators. | |
| 124 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr); | |
| 125 inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { | |
| 126 return out << wstr.c_str(); | |
| 127 } | |
| 128 | |
| 129 namespace logging { | 117 namespace logging { |
| 130 | 118 |
| 131 // Where to record logging output? A flat file and/or system debug log via | 119 // Where to record logging output? A flat file and/or system debug log via |
| 132 // OutputDebugString. Defaults on Windows to LOG_ONLY_TO_FILE, and on | 120 // OutputDebugString. Defaults on Windows to LOG_ONLY_TO_FILE, and on |
| 133 // POSIX to LOG_ONLY_TO_SYSTEM_DEBUG_LOG (aka stderr). | 121 // POSIX to LOG_ONLY_TO_SYSTEM_DEBUG_LOG (aka stderr). |
| 134 enum LoggingDestination { LOG_NONE, | 122 enum LoggingDestination { LOG_NONE, |
| 135 LOG_ONLY_TO_FILE, | 123 LOG_ONLY_TO_FILE, |
| 136 LOG_ONLY_TO_SYSTEM_DEBUG_LOG, | 124 LOG_ONLY_TO_SYSTEM_DEBUG_LOG, |
| 137 LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG }; | 125 LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG }; |
| 138 | 126 |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 #elif NOTIMPLEMENTED_POLICY == 4 | 890 #elif NOTIMPLEMENTED_POLICY == 4 |
| 903 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG | 891 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG |
| 904 #elif NOTIMPLEMENTED_POLICY == 5 | 892 #elif NOTIMPLEMENTED_POLICY == 5 |
| 905 #define NOTIMPLEMENTED() do {\ | 893 #define NOTIMPLEMENTED() do {\ |
| 906 static int count = 0;\ | 894 static int count = 0;\ |
| 907 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ | 895 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ |
| 908 } while(0) | 896 } while(0) |
| 909 #endif | 897 #endif |
| 910 | 898 |
| 911 #endif // BASE_LOGGING_H_ | 899 #endif // BASE_LOGGING_H_ |
| OLD | NEW |