Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: base/logging.h

Issue 2825006: Revert 49982 - patch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/linked_list.h ('k') | base/message_loop_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include <string> 8 #include <string>
9 #include <cstring> 9 #include <cstring>
10 #include <sstream> 10 #include <sstream>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Very important: logging a message at the FATAL severity level causes 94 // Very important: logging a message at the FATAL severity level causes
95 // the program to terminate (after the message is logged). 95 // the program to terminate (after the message is logged).
96 // 96 //
97 // Note the special severity of ERROR_REPORT only available/relevant in normal 97 // Note the special severity of ERROR_REPORT only available/relevant in normal
98 // mode, which displays error dialog without terminating the program. There is 98 // mode, which displays error dialog without terminating the program. There is
99 // no error dialog for severity ERROR or below in normal mode. 99 // no error dialog for severity ERROR or below in normal mode.
100 // 100 //
101 // There is also the special severity of DFATAL, which logs FATAL in 101 // There is also the special severity of DFATAL, which logs FATAL in
102 // debug mode, ERROR_REPORT in normal mode. 102 // debug mode, ERROR_REPORT in normal mode.
103 103
104 // XXX better comment -- must be before we use << and in global namespace
105 // These functions are provided as a convenience for logging, which is where we
106 // use streams (it is against Google style to use streams in other places). It
107 // is designed to allow you to emit non-ASCII Unicode strings to the log file,
108 // which is normally ASCII. It is relatively slow, so try not to use it for
109 // common cases. Non-ASCII characters will be converted to UTF-8 by these
110 // operators.
111 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr);
112 inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
113 return out << wstr.c_str();
114 }
115
116 namespace logging { 104 namespace logging {
117 105
118 // Where to record logging output? A flat file and/or system debug log via 106 // Where to record logging output? A flat file and/or system debug log via
119 // OutputDebugString. Defaults on Windows to LOG_ONLY_TO_FILE, and on 107 // OutputDebugString. Defaults on Windows to LOG_ONLY_TO_FILE, and on
120 // POSIX to LOG_ONLY_TO_SYSTEM_DEBUG_LOG (aka stderr). 108 // POSIX to LOG_ONLY_TO_SYSTEM_DEBUG_LOG (aka stderr).
121 enum LoggingDestination { LOG_NONE, 109 enum LoggingDestination { LOG_NONE,
122 LOG_ONLY_TO_FILE, 110 LOG_ONLY_TO_FILE,
123 LOG_ONLY_TO_SYSTEM_DEBUG_LOG, 111 LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
124 LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG }; 112 LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG };
125 113
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 #define RAW_LOG(level, message) logging::RawLog(logging::LOG_ ## level, message) 806 #define RAW_LOG(level, message) logging::RawLog(logging::LOG_ ## level, message)
819 807
820 #define RAW_CHECK(condition) \ 808 #define RAW_CHECK(condition) \
821 do { \ 809 do { \
822 if (!(condition)) \ 810 if (!(condition)) \
823 logging::RawLog(logging::LOG_FATAL, "Check failed: " #condition "\n"); \ 811 logging::RawLog(logging::LOG_FATAL, "Check failed: " #condition "\n"); \
824 } while (0) 812 } while (0)
825 813
826 } // namespace logging 814 } // namespace logging
827 815
816 // These functions are provided as a convenience for logging, which is where we
817 // use streams (it is against Google style to use streams in other places). It
818 // is designed to allow you to emit non-ASCII Unicode strings to the log file,
819 // which is normally ASCII. It is relatively slow, so try not to use it for
820 // common cases. Non-ASCII characters will be converted to UTF-8 by these
821 // operators.
822 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr);
823 inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
824 return out << wstr.c_str();
825 }
826
828 // The NOTIMPLEMENTED() macro annotates codepaths which have 827 // The NOTIMPLEMENTED() macro annotates codepaths which have
829 // not been implemented yet. 828 // not been implemented yet.
830 // 829 //
831 // The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY: 830 // The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY:
832 // 0 -- Do nothing (stripped by compiler) 831 // 0 -- Do nothing (stripped by compiler)
833 // 1 -- Warn at compile time 832 // 1 -- Warn at compile time
834 // 2 -- Fail at compile time 833 // 2 -- Fail at compile time
835 // 3 -- Fail at runtime (DCHECK) 834 // 3 -- Fail at runtime (DCHECK)
836 // 4 -- [default] LOG(ERROR) at runtime 835 // 4 -- [default] LOG(ERROR) at runtime
837 // 5 -- LOG(ERROR) at runtime, only once per call-site 836 // 5 -- LOG(ERROR) at runtime, only once per call-site
(...skipping 23 matching lines...) Expand all
861 #elif NOTIMPLEMENTED_POLICY == 4 860 #elif NOTIMPLEMENTED_POLICY == 4
862 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG 861 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG
863 #elif NOTIMPLEMENTED_POLICY == 5 862 #elif NOTIMPLEMENTED_POLICY == 5
864 #define NOTIMPLEMENTED() do {\ 863 #define NOTIMPLEMENTED() do {\
865 static int count = 0;\ 864 static int count = 0;\
866 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ 865 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\
867 } while(0) 866 } while(0)
868 #endif 867 #endif
869 868
870 #endif // BASE_LOGGING_H_ 869 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « base/linked_list.h ('k') | base/message_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698