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

Side by Side Diff: sdch/open_vcdiff/depot/opensource/open-vcdiff/src/logging.h

Issue 5203: Transition to pulling open-vcdiff from repository, instead of using snapshot... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 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
OLDNEW
(Empty)
1 // Copyright 2008 Google Inc.
2 // Author: Lincoln Smith
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15
16 #ifndef OPEN_VCDIFF_LOGGING_H_
17 #define OPEN_VCDIFF_LOGGING_H_
18
19 #include <config.h>
20 #include <iostream>
21 #include <vector>
22
23 // Windows API defines ERROR
24 #ifdef ERROR
25 #undef ERROR
26 #endif // ERROR
27
28 namespace open_vcdiff {
29
30 enum LogLevel {
31 INFO,
32 WARNING,
33 ERROR,
34 FATAL
35 };
36
37 #ifndef NDEBUG
38 #define DFATAL FATAL
39 #else // NDEBUG
40 #define DFATAL ERROR
41 #endif // !NDEBUG
42
43 extern bool g_fatal_error_occurred;
44 extern void (*ExitFatal)();
45
46 inline std::ostream& LogMessage(LogLevel level, const char* level_name) {
47 if (level == FATAL) {
48 g_fatal_error_occurred = true;
49 }
50 return std::cerr << level_name << ": ";
51 }
52
53 inline void CheckFatalError() {
54 if (g_fatal_error_occurred) {
55 g_fatal_error_occurred = false;
56 (*ExitFatal)();
57 }
58 }
59
60 } // namespace open_vcdiff
61
62 #define LOG(level) LogMessage(open_vcdiff::level, #level)
63 #define LOG_ENDL std::endl; \
64 open_vcdiff::CheckFatalError();
65
66 #endif // OPEN_VCDIFF_LOGGING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698