OLD | NEW |
1 // Copyright (c) 2011 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> |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 // takes ownership of the returned string. | 461 // takes ownership of the returned string. |
462 template<class t1, class t2> | 462 template<class t1, class t2> |
463 std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { | 463 std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { |
464 std::ostringstream ss; | 464 std::ostringstream ss; |
465 ss << names << " (" << v1 << " vs. " << v2 << ")"; | 465 ss << names << " (" << v1 << " vs. " << v2 << ")"; |
466 std::string* msg = new std::string(ss.str()); | 466 std::string* msg = new std::string(ss.str()); |
467 return msg; | 467 return msg; |
468 } | 468 } |
469 | 469 |
470 // MSVC doesn't like complex extern templates and DLLs. | 470 // MSVC doesn't like complex extern templates and DLLs. |
471 #if !defined(COMPILER_MSVC) | 471 #if !defined(COMPILER_MSVC) && defined(BASE_DLL) |
472 // Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated | 472 // Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated |
473 // in logging.cc. | 473 // in logging.cc. |
474 extern template std::string* MakeCheckOpString<int, int>( | 474 extern template std::string* MakeCheckOpString<int, int>( |
475 const int&, const int&, const char* names); | 475 const int&, const int&, const char* names); |
476 extern template std::string* MakeCheckOpString<unsigned long, unsigned long>( | 476 extern template std::string* MakeCheckOpString<unsigned long, unsigned long>( |
477 const unsigned long&, const unsigned long&, const char* names); | 477 const unsigned long&, const unsigned long&, const char* names); |
478 extern template std::string* MakeCheckOpString<unsigned long, unsigned int>( | 478 extern template std::string* MakeCheckOpString<unsigned long, unsigned int>( |
479 const unsigned long&, const unsigned int&, const char* names); | 479 const unsigned long&, const unsigned int&, const char* names); |
480 extern template std::string* MakeCheckOpString<unsigned int, unsigned long>( | 480 extern template std::string* MakeCheckOpString<unsigned int, unsigned long>( |
481 const unsigned int&, const unsigned long&, const char* names); | 481 const unsigned int&, const unsigned long&, const char* names); |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 private: | 835 private: |
836 SystemErrorCode err_; | 836 SystemErrorCode err_; |
837 // Optional name of the module defining the error. | 837 // Optional name of the module defining the error. |
838 const char* module_; | 838 const char* module_; |
839 LogMessage log_message_; | 839 LogMessage log_message_; |
840 | 840 |
841 DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage); | 841 DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage); |
842 }; | 842 }; |
843 #elif defined(OS_POSIX) | 843 #elif defined(OS_POSIX) |
844 // Appends a formatted system message of the errno type | 844 // Appends a formatted system message of the errno type |
845 class ErrnoLogMessage { | 845 class BASE_API ErrnoLogMessage { |
846 public: | 846 public: |
847 ErrnoLogMessage(const char* file, | 847 ErrnoLogMessage(const char* file, |
848 int line, | 848 int line, |
849 LogSeverity severity, | 849 LogSeverity severity, |
850 SystemErrorCode err); | 850 SystemErrorCode err); |
851 | 851 |
852 // Appends the error message before destructing the encapsulated class. | 852 // Appends the error message before destructing the encapsulated class. |
853 ~ErrnoLogMessage(); | 853 ~ErrnoLogMessage(); |
854 | 854 |
855 std::ostream& stream() { return log_message_.stream(); } | 855 std::ostream& stream() { return log_message_.stream(); } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 namespace base { | 937 namespace base { |
938 | 938 |
939 class StringPiece; | 939 class StringPiece; |
940 | 940 |
941 // Allows StringPiece to be logged. | 941 // Allows StringPiece to be logged. |
942 BASE_API std::ostream& operator<<(std::ostream& o, const StringPiece& piece); | 942 BASE_API std::ostream& operator<<(std::ostream& o, const StringPiece& piece); |
943 | 943 |
944 } // namespace base | 944 } // namespace base |
945 | 945 |
946 #endif // BASE_LOGGING_H_ | 946 #endif // BASE_LOGGING_H_ |
OLD | NEW |