1 // This file is automatically generated from src/glog/raw_logging.h.in
2 // using src/windows/preprocess.sh.
5 // Copyright 2006 Google Inc. All Rights Reserved.
6 // Author: Maxim Lifantsev
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.
12 #ifndef BASE_RAW_LOGGING_H__
13 #define BASE_RAW_LOGGING_H__
17 #include "glog/log_severity.h"
18 #include "glog/vlog_is_on.h"
20 // Annoying stuff for windows -- makes sure clients can import these functions
21 #ifndef GOOGLE_GLOG_DLL_DECL
23 # define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
25 # define GOOGLE_GLOG_DLL_DECL
29 // This is similar to LOG(severity) << format... and VLOG(level) << format..,
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
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, ...) \
45 google::RawLog__(google::severity, __FILE__, __LINE__, __VA_ARGS__); \
48 #define RAW_VLOG(verboselevel, ...) \
50 if (VLOG_IS_ON(verboselevel)) { \
51 google::RawLog__(google::INFO, __FILE__, __LINE__, __VA_ARGS__); \
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) \
63 RAW_LOG(FATAL, "Check %s failed: %s", #condition, message); \
67 // Debug versions of RAW_LOG and RAW_CHECK
70 #define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__)
71 #define RAW_DCHECK(condition, message) RAW_CHECK(condition, message)
75 #define RAW_DLOG(severity, ...) \
77 RAW_LOG(severity, __VA_ARGS__)
78 #define RAW_DCHECK(condition, message) \
80 RAW_CHECK(condition, message)
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,
91 const char* format, ...)
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);
102 #endif // BASE_RAW_LOGGING_H__