| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
| 11 #include <sstream> | 11 #include <sstream> |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 int line, | 796 int line, |
| 797 LogSeverity severity, | 797 LogSeverity severity, |
| 798 SystemErrorCode err, | 798 SystemErrorCode err, |
| 799 const char* module); | 799 const char* module); |
| 800 | 800 |
| 801 Win32ErrorLogMessage(const char* file, | 801 Win32ErrorLogMessage(const char* file, |
| 802 int line, | 802 int line, |
| 803 LogSeverity severity, | 803 LogSeverity severity, |
| 804 SystemErrorCode err); | 804 SystemErrorCode err); |
| 805 | 805 |
| 806 std::ostream& stream() { return log_message_.stream(); } | |
| 807 | |
| 808 // Appends the error message before destructing the encapsulated class. | 806 // Appends the error message before destructing the encapsulated class. |
| 809 ~Win32ErrorLogMessage(); | 807 ~Win32ErrorLogMessage(); |
| 810 | 808 |
| 809 std::ostream& stream() { return log_message_.stream(); } |
| 810 |
| 811 private: | 811 private: |
| 812 SystemErrorCode err_; | 812 SystemErrorCode err_; |
| 813 // Optional name of the module defining the error. | 813 // Optional name of the module defining the error. |
| 814 const char* module_; | 814 const char* module_; |
| 815 LogMessage log_message_; | 815 LogMessage log_message_; |
| 816 | 816 |
| 817 DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage); | 817 DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage); |
| 818 }; | 818 }; |
| 819 #elif defined(OS_POSIX) | 819 #elif defined(OS_POSIX) |
| 820 // Appends a formatted system message of the errno type | 820 // Appends a formatted system message of the errno type |
| 821 class ErrnoLogMessage { | 821 class ErrnoLogMessage { |
| 822 public: | 822 public: |
| 823 ErrnoLogMessage(const char* file, | 823 ErrnoLogMessage(const char* file, |
| 824 int line, | 824 int line, |
| 825 LogSeverity severity, | 825 LogSeverity severity, |
| 826 SystemErrorCode err); | 826 SystemErrorCode err); |
| 827 | 827 |
| 828 std::ostream& stream() { return log_message_.stream(); } | |
| 829 | |
| 830 // Appends the error message before destructing the encapsulated class. | 828 // Appends the error message before destructing the encapsulated class. |
| 831 ~ErrnoLogMessage(); | 829 ~ErrnoLogMessage(); |
| 832 | 830 |
| 831 std::ostream& stream() { return log_message_.stream(); } |
| 832 |
| 833 private: | 833 private: |
| 834 SystemErrorCode err_; | 834 SystemErrorCode err_; |
| 835 LogMessage log_message_; | 835 LogMessage log_message_; |
| 836 | 836 |
| 837 DISALLOW_COPY_AND_ASSIGN(ErrnoLogMessage); | 837 DISALLOW_COPY_AND_ASSIGN(ErrnoLogMessage); |
| 838 }; | 838 }; |
| 839 #endif // OS_WIN | 839 #endif // OS_WIN |
| 840 | 840 |
| 841 // Closes the log file explicitly if open. | 841 // Closes the log file explicitly if open. |
| 842 // NOTE: Since the log file is opened as necessary by the action of logging | 842 // NOTE: Since the log file is opened as necessary by the action of logging |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 #elif NOTIMPLEMENTED_POLICY == 4 | 904 #elif NOTIMPLEMENTED_POLICY == 4 |
| 905 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG | 905 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG |
| 906 #elif NOTIMPLEMENTED_POLICY == 5 | 906 #elif NOTIMPLEMENTED_POLICY == 5 |
| 907 #define NOTIMPLEMENTED() do {\ | 907 #define NOTIMPLEMENTED() do {\ |
| 908 static int count = 0;\ | 908 static int count = 0;\ |
| 909 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ | 909 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ |
| 910 } while(0) | 910 } while(0) |
| 911 #endif | 911 #endif |
| 912 | 912 |
| 913 #endif // BASE_LOGGING_H_ | 913 #endif // BASE_LOGGING_H_ |
| OLD | NEW |