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 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <cstring> | 9 #include <cstring> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 DISALLOW_COPY_AND_ASSIGN(ErrnoLogMessage); | 765 DISALLOW_COPY_AND_ASSIGN(ErrnoLogMessage); |
766 }; | 766 }; |
767 #endif // OS_WIN | 767 #endif // OS_WIN |
768 | 768 |
769 // Closes the log file explicitly if open. | 769 // Closes the log file explicitly if open. |
770 // NOTE: Since the log file is opened as necessary by the action of logging | 770 // NOTE: Since the log file is opened as necessary by the action of logging |
771 // statements, there's no guarantee that it will stay closed | 771 // statements, there's no guarantee that it will stay closed |
772 // after this call. | 772 // after this call. |
773 void CloseLogFile(); | 773 void CloseLogFile(); |
774 | 774 |
| 775 // Async signal safe logging mechanism. |
| 776 void RawLog(int level, const char* message); |
| 777 |
| 778 #define RAW_LOG(level, message) logging::RawLog(logging::LOG_ ## level, message) |
| 779 |
| 780 #define RAW_CHECK(condition) \ |
| 781 do { \ |
| 782 if (!(condition)) \ |
| 783 logging::RawLog(logging::LOG_FATAL, "Check failed: " #condition "\n"); \ |
| 784 } while (0) |
| 785 |
775 } // namespace logging | 786 } // namespace logging |
776 | 787 |
777 // These functions are provided as a convenience for logging, which is where we | 788 // These functions are provided as a convenience for logging, which is where we |
778 // use streams (it is against Google style to use streams in other places). It | 789 // use streams (it is against Google style to use streams in other places). It |
779 // is designed to allow you to emit non-ASCII Unicode strings to the log file, | 790 // is designed to allow you to emit non-ASCII Unicode strings to the log file, |
780 // which is normally ASCII. It is relatively slow, so try not to use it for | 791 // which is normally ASCII. It is relatively slow, so try not to use it for |
781 // common cases. Non-ASCII characters will be converted to UTF-8 by these | 792 // common cases. Non-ASCII characters will be converted to UTF-8 by these |
782 // operators. | 793 // operators. |
783 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr); | 794 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr); |
784 inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { | 795 inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 #elif NOTIMPLEMENTED_POLICY == 4 | 832 #elif NOTIMPLEMENTED_POLICY == 4 |
822 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG | 833 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG |
823 #elif NOTIMPLEMENTED_POLICY == 5 | 834 #elif NOTIMPLEMENTED_POLICY == 5 |
824 #define NOTIMPLEMENTED() do {\ | 835 #define NOTIMPLEMENTED() do {\ |
825 static int count = 0;\ | 836 static int count = 0;\ |
826 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ | 837 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ |
827 } while(0) | 838 } while(0) |
828 #endif | 839 #endif |
829 | 840 |
830 #endif // BASE_LOGGING_H_ | 841 #endif // BASE_LOGGING_H_ |
OLD | NEW |