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