Initial windows support. Now we don't have the stacktrace and several unittests.
[platform/upstream/glog.git] / src / glog / log_severity.h
1 // Copyright 2007 Google Inc. All Rights Reserved.
2
3 #ifndef BASE_LOG_SEVERITY_H__
4 #define BASE_LOG_SEVERITY_H__
5
6 // Annoying stuff for windows -- makes sure clients can import these functions
7 #ifndef GOOGLE_GLOG_DLL_DECL
8 # ifdef _WIN32
9 #   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
10 # else
11 #   define GOOGLE_GLOG_DLL_DECL
12 # endif
13 #endif
14
15 // Variables of type LogSeverity are widely taken to lie in the range
16 // [0, NUM_SEVERITIES-1].  Be careful to preserve this assumption if
17 // you ever need to change their values or add a new severity.
18 typedef int LogSeverity;
19
20 const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4;
21
22 // DFATAL is FATAL in debug mode, ERROR in normal mode
23 #ifdef NDEBUG
24 #define DFATAL_LEVEL ERROR
25 #else
26 #define DFATAL_LEVEL FATAL
27 #endif
28
29 extern GOOGLE_GLOG_DLL_DECL const char* const LogSeverityNames[NUM_SEVERITIES];
30
31 // NDEBUG usage helpers related to (RAW_)DCHECK:
32 //
33 // DEBUG_MODE is for small !NDEBUG uses like
34 //   if (DEBUG_MODE) foo.CheckThatFoo();
35 // instead of substantially more verbose
36 //   #ifndef NDEBUG
37 //     foo.CheckThatFoo();
38 //   #endif
39 //
40 // IF_DEBUG_MODE is for small !NDEBUG uses like
41 //   IF_DEBUG_MODE( string error; )
42 //   DCHECK(Foo(&error)) << error;
43 // instead of substantially more verbose
44 //   #ifndef NDEBUG
45 //     string error;
46 //     DCHECK(Foo(&error)) << error;
47 //   #endif
48 //
49 #ifdef NDEBUG
50 enum { DEBUG_MODE = 0 };
51 #define IF_DEBUG_MODE(x)
52 #else
53 enum { DEBUG_MODE = 1 };
54 #define IF_DEBUG_MODE(x) x
55 #endif
56
57 #endif  // BASE_LOG_SEVERITY_H__