Initial windows support. Now we don't have the stacktrace and several unittests.
[platform/upstream/glog.git] / src / windows / glog / raw_logging.h
1 // This file is automatically generated from src/glog/raw_logging.h.in
2 // using src/windows/preprocess.sh.
3 // DO NOT EDIT!
4
5 // Copyright 2006 Google Inc. All Rights Reserved.
6 // Author: Maxim Lifantsev
7 //
8 // Logging routines that do not allocate any memory and acquire any
9 // locks, and can therefore be used by low-level memory allocation
10 // and synchronization code.
11
12 #ifndef BASE_RAW_LOGGING_H__
13 #define BASE_RAW_LOGGING_H__
14
15 namespace google {
16
17 #include "glog/log_severity.h"
18 #include "glog/vlog_is_on.h"
19
20 // Annoying stuff for windows -- makes sure clients can import these functions
21 #ifndef GOOGLE_GLOG_DLL_DECL
22 # ifdef _WIN32
23 #   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
24 # else
25 #   define GOOGLE_GLOG_DLL_DECL
26 # endif
27 #endif
28
29 // This is similar to LOG(severity) << format... and VLOG(level) << format..,
30 // but
31 // * it is to be used ONLY by low-level modules that can't use normal LOG()
32 // * it is desiged to be a low-level logger that does not allocate any
33 //   memory and does not need any locks, hence:
34 // * it logs straight and ONLY to STDERR w/o buffering
35 // * it uses an explicit format and arguments list
36 // * it will silently chop off really long message strings
37 // Usage example:
38 //   RAW_LOG(ERROR, "Failed foo with %i: %s", status, error);
39 //   RAW_VLOG(3, "status is %i", status);
40 // These will print an almost standard log lines like this to stderr only:
41 //   E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file
42 //   I0821 211317 file.cc:142] RAW: status is 20
43 #define RAW_LOG(severity, ...) \
44   do { \
45     google::RawLog__(google::severity, __FILE__,  __LINE__, __VA_ARGS__); \
46   } while (0)
47
48 #define RAW_VLOG(verboselevel, ...) \
49   do { \
50     if (VLOG_IS_ON(verboselevel)) { \
51       google::RawLog__(google::INFO, __FILE__,  __LINE__, __VA_ARGS__); \
52     } \
53   } while (0)
54
55 // Similar to CHECK(condition) << message,
56 // but for low-level modules: we use only RAW_LOG that does not allocate memory.
57 // We do not want to provide args list here to encourage this usage:
58 //   if (!cond)  RAW_LOG(FATAL, "foo ...", hard_to_compute_args);
59 // so that the args are not computed when not needed.
60 #define RAW_CHECK(condition, message) \
61   do { \
62     if (!(condition)) { \
63       RAW_LOG(FATAL, "Check %s failed: %s", #condition, message); \
64     } \
65   } while (0)
66
67 // Debug versions of RAW_LOG and RAW_CHECK
68 #ifndef NDEBUG
69
70 #define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__)
71 #define RAW_DCHECK(condition, message) RAW_CHECK(condition, message)
72
73 #else  // NDEBUG
74
75 #define RAW_DLOG(severity, ...) \
76   while (false) \
77     RAW_LOG(severity, __VA_ARGS__)
78 #define RAW_DCHECK(condition, message) \
79   while (false) \
80     RAW_CHECK(condition, message)
81
82 #endif  // NDEBUG
83
84 // Helper function to implement RAW_LOG and RAW_VLOG
85 // Logs format... at "severity" level, reporting it
86 // as called from file:line.
87 // This does not allocate memory or acquire locks.
88 GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity,
89                                    const char* file,
90                                    int line,
91                                    const char* format, ...)
92    ;
93
94 // Hack to propagate time information into this module so that
95 // this module does not have to directly call localtime_r(),
96 // which could allocate memory.
97 extern "C" struct ::tm;
98 GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct ::tm& t);
99
100 }
101
102 #endif  // BASE_RAW_LOGGING_H__