| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cassert> | 8 #include <cassert> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 // This class more or less represents a particular log message. You | 677 // This class more or less represents a particular log message. You |
| 678 // create an instance of LogMessage and then stream stuff to it. | 678 // create an instance of LogMessage and then stream stuff to it. |
| 679 // When you finish streaming to it, ~LogMessage is called and the | 679 // When you finish streaming to it, ~LogMessage is called and the |
| 680 // full message gets streamed to the appropriate destination. | 680 // full message gets streamed to the appropriate destination. |
| 681 // | 681 // |
| 682 // You shouldn't actually use LogMessage's constructor to log things, | 682 // You shouldn't actually use LogMessage's constructor to log things, |
| 683 // though. You should use the LOG() macro (and variants thereof) | 683 // though. You should use the LOG() macro (and variants thereof) |
| 684 // above. | 684 // above. |
| 685 class BASE_EXPORT LogMessage { | 685 class BASE_EXPORT LogMessage { |
| 686 public: | 686 public: |
| 687 LogMessage(const char* file, int line, LogSeverity severity, int ctr); | 687 // Used for LOG(severity). |
| 688 | |
| 689 // Two special constructors that generate reduced amounts of code at | |
| 690 // LOG call sites for common cases. | |
| 691 // | |
| 692 // Used for LOG(INFO): Implied are: | |
| 693 // severity = LOG_INFO, ctr = 0 | |
| 694 // | |
| 695 // Using this constructor instead of the more complex constructor above | |
| 696 // saves a couple of bytes per call site. | |
| 697 LogMessage(const char* file, int line); | |
| 698 | |
| 699 // Used for LOG(severity) where severity != INFO. Implied | |
| 700 // are: ctr = 0 | |
| 701 // | |
| 702 // Using this constructor instead of the more complex constructor above | |
| 703 // saves a couple of bytes per call site. | |
| 704 LogMessage(const char* file, int line, LogSeverity severity); | 688 LogMessage(const char* file, int line, LogSeverity severity); |
| 705 | 689 |
| 706 // A special constructor used for check failures. Takes ownership | 690 // Used for CHECK_EQ(), etc. Takes ownership of the given string. |
| 707 // of the given string. | 691 // Implied severity = LOG_FATAL. |
| 708 // Implied severity = LOG_FATAL | |
| 709 LogMessage(const char* file, int line, std::string* result); | 692 LogMessage(const char* file, int line, std::string* result); |
| 710 | 693 |
| 711 // A special constructor used for check failures, with the option to | 694 // Used for DCHECK_EQ(), etc. Takes ownership of the given string. |
| 712 // specify severity. Takes ownership of the given string. | |
| 713 LogMessage(const char* file, int line, LogSeverity severity, | 695 LogMessage(const char* file, int line, LogSeverity severity, |
| 714 std::string* result); | 696 std::string* result); |
| 715 | 697 |
| 716 ~LogMessage(); | 698 ~LogMessage(); |
| 717 | 699 |
| 718 std::ostream& stream() { return stream_; } | 700 std::ostream& stream() { return stream_; } |
| 719 | 701 |
| 720 private: | 702 private: |
| 721 void Init(const char* file, int line); | 703 void Init(const char* file, int line); |
| 722 | 704 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 #elif NOTIMPLEMENTED_POLICY == 5 | 880 #elif NOTIMPLEMENTED_POLICY == 5 |
| 899 #define NOTIMPLEMENTED() do {\ | 881 #define NOTIMPLEMENTED() do {\ |
| 900 static bool logged_once = false;\ | 882 static bool logged_once = false;\ |
| 901 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 883 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 902 logged_once = true;\ | 884 logged_once = true;\ |
| 903 } while(0);\ | 885 } while(0);\ |
| 904 EAT_STREAM_PARAMETERS | 886 EAT_STREAM_PARAMETERS |
| 905 #endif | 887 #endif |
| 906 | 888 |
| 907 #endif // BASE_LOGGING_H_ | 889 #endif // BASE_LOGGING_H_ |
| OLD | NEW |