Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/re2/util/logging.h

Issue 10873029: Migrate WebRequestRedirectByRegExAction to use RE2 and roll RE2 to revision 97:401ab4168e8e (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/re2/re2/testing/set_test.cc ('k') | third_party/re2/util/mutex.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The RE2 Authors. All Rights Reserved. 1 // Copyright 2009 The RE2 Authors. All Rights Reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Simplified version of Google's logging. 5 // Simplified version of Google's logging.
6 6
7 #ifndef RE2_UTIL_LOGGING_H__ 7 #ifndef RE2_UTIL_LOGGING_H__
8 #define RE2_UTIL_LOGGING_H__ 8 #define RE2_UTIL_LOGGING_H__
9 9
10 #ifndef WIN32 10 #ifndef WIN32
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #define LOG_DFATAL LOG_ERROR 46 #define LOG_DFATAL LOG_ERROR
47 #else 47 #else
48 #define DEBUG_MODE 1 48 #define DEBUG_MODE 1
49 #define LOG_DFATAL LOG_FATAL 49 #define LOG_DFATAL LOG_FATAL
50 #endif 50 #endif
51 51
52 #define LOG(severity) LOG_ ## severity.stream() 52 #define LOG(severity) LOG_ ## severity.stream()
53 53
54 class LogMessage { 54 class LogMessage {
55 public: 55 public:
56 LogMessage(const char* file, int line) { 56 LogMessage(const char* file, int line) : flushed_(false) {
57 stream() << file << ":" << line << ": "; 57 stream() << file << ":" << line << ": ";
58 } 58 }
59 ~LogMessage() { 59 void Flush() {
60 stream() << "\n"; 60 stream() << "\n";
61 string s = str_.str(); 61 string s = str_.str();
62 if(write(2, s.data(), s.size()) < 0) {} // shut up gcc 62 if(write(2, s.data(), s.size()) < 0) {} // shut up gcc
63 flushed_ = true;
64 }
65 ~LogMessage() {
66 if (!flushed_) {
67 Flush();
68 }
63 } 69 }
64 ostream& stream() { return str_; } 70 ostream& stream() { return str_; }
65 71
66 private: 72 private:
73 bool flushed_;
67 std::ostringstream str_; 74 std::ostringstream str_;
68 DISALLOW_EVIL_CONSTRUCTORS(LogMessage); 75 DISALLOW_EVIL_CONSTRUCTORS(LogMessage);
69 }; 76 };
70 77
71 class LogMessageFatal : public LogMessage { 78 class LogMessageFatal : public LogMessage {
72 public: 79 public:
73 LogMessageFatal(const char* file, int line) 80 LogMessageFatal(const char* file, int line)
74 : LogMessage(file, line) { } 81 : LogMessage(file, line) { }
75 ~LogMessageFatal() { 82 ~LogMessageFatal() {
76 std::cerr << "\n"; 83 Flush();
77 abort(); 84 abort();
78 } 85 }
79 private: 86 private:
80 DISALLOW_EVIL_CONSTRUCTORS(LogMessageFatal); 87 DISALLOW_EVIL_CONSTRUCTORS(LogMessageFatal);
81 }; 88 };
82 89
83 #endif // RE2_UTIL_LOGGING_H__ 90 #endif // RE2_UTIL_LOGGING_H__
OLDNEW
« no previous file with comments | « third_party/re2/re2/testing/set_test.cc ('k') | third_party/re2/util/mutex.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698