PageRenderTime 24ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/thirdparty/breakpad/third_party/glog/src/windows/glog/raw_logging.h

http://github.com/tomahawk-player/tomahawk
C Header | 189 lines | 97 code | 23 blank | 69 comment | 13 complexity | 25b148d302f949811f57669aaca61d36 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-3.0, GPL-2.0
  1. // This file is automatically generated from src/glog/raw_logging.h.in
  2. // using src/windows/preprocess.sh.
  3. // DO NOT EDIT!
  4. // Copyright (c) 2006, Google Inc.
  5. // All rights reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions are
  9. // met:
  10. //
  11. // * Redistributions of source code must retain the above copyright
  12. // notice, this list of conditions and the following disclaimer.
  13. // * Redistributions in binary form must reproduce the above
  14. // copyright notice, this list of conditions and the following disclaimer
  15. // in the documentation and/or other materials provided with the
  16. // distribution.
  17. // * Neither the name of Google Inc. nor the names of its
  18. // contributors may be used to endorse or promote products derived from
  19. // this software without specific prior written permission.
  20. //
  21. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. //
  33. // Author: Maxim Lifantsev
  34. //
  35. // Thread-safe logging routines that do not allocate any memory or
  36. // acquire any locks, and can therefore be used by low-level memory
  37. // allocation and synchronization code.
  38. #ifndef BASE_RAW_LOGGING_H_
  39. #define BASE_RAW_LOGGING_H_
  40. #include <time.h>
  41. namespace google {
  42. #include "glog/log_severity.h"
  43. #include "glog/vlog_is_on.h"
  44. // Annoying stuff for windows -- makes sure clients can import these functions
  45. #ifndef GOOGLE_GLOG_DLL_DECL
  46. # if defined(_WIN32) && !defined(__CYGWIN__)
  47. # define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
  48. # else
  49. # define GOOGLE_GLOG_DLL_DECL
  50. # endif
  51. #endif
  52. // This is similar to LOG(severity) << format... and VLOG(level) << format..,
  53. // but
  54. // * it is to be used ONLY by low-level modules that can't use normal LOG()
  55. // * it is desiged to be a low-level logger that does not allocate any
  56. // memory and does not need any locks, hence:
  57. // * it logs straight and ONLY to STDERR w/o buffering
  58. // * it uses an explicit format and arguments list
  59. // * it will silently chop off really long message strings
  60. // Usage example:
  61. // RAW_LOG(ERROR, "Failed foo with %i: %s", status, error);
  62. // RAW_VLOG(3, "status is %i", status);
  63. // These will print an almost standard log lines like this to stderr only:
  64. // E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file
  65. // I0821 211317 file.cc:142] RAW: status is 20
  66. #define RAW_LOG(severity, ...) \
  67. do { \
  68. switch (google::severity) { \
  69. case 0: \
  70. RAW_LOG_INFO(__VA_ARGS__); \
  71. break; \
  72. case 1: \
  73. RAW_LOG_WARNING(__VA_ARGS__); \
  74. break; \
  75. case 2: \
  76. RAW_LOG_ERROR(__VA_ARGS__); \
  77. break; \
  78. case 3: \
  79. RAW_LOG_FATAL(__VA_ARGS__); \
  80. break; \
  81. default: \
  82. break; \
  83. } \
  84. } while (0)
  85. // The following STRIP_LOG testing is performed in the header file so that it's
  86. // possible to completely compile out the logging code and the log messages.
  87. #if STRIP_LOG == 0
  88. #define RAW_VLOG(verboselevel, ...) \
  89. do { \
  90. if (VLOG_IS_ON(verboselevel)) { \
  91. RAW_LOG_INFO(__VA_ARGS__); \
  92. } \
  93. } while (0)
  94. #else
  95. #define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__)
  96. #endif // STRIP_LOG == 0
  97. #if STRIP_LOG == 0
  98. #define RAW_LOG_INFO(...) google::RawLog__(google::INFO, \
  99. __FILE__, __LINE__, __VA_ARGS__)
  100. #else
  101. #define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
  102. #endif // STRIP_LOG == 0
  103. #if STRIP_LOG <= 1
  104. #define RAW_LOG_WARNING(...) google::RawLog__(google::WARNING, \
  105. __FILE__, __LINE__, __VA_ARGS__)
  106. #else
  107. #define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
  108. #endif // STRIP_LOG <= 1
  109. #if STRIP_LOG <= 2
  110. #define RAW_LOG_ERROR(...) google::RawLog__(google::ERROR, \
  111. __FILE__, __LINE__, __VA_ARGS__)
  112. #else
  113. #define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
  114. #endif // STRIP_LOG <= 2
  115. #if STRIP_LOG <= 3
  116. #define RAW_LOG_FATAL(...) google::RawLog__(google::FATAL, \
  117. __FILE__, __LINE__, __VA_ARGS__)
  118. #else
  119. #define RAW_LOG_FATAL(...) \
  120. do { \
  121. google::RawLogStub__(0, __VA_ARGS__); \
  122. exit(1); \
  123. } while (0)
  124. #endif // STRIP_LOG <= 3
  125. // Similar to CHECK(condition) << message,
  126. // but for low-level modules: we use only RAW_LOG that does not allocate memory.
  127. // We do not want to provide args list here to encourage this usage:
  128. // if (!cond) RAW_LOG(FATAL, "foo ...", hard_to_compute_args);
  129. // so that the args are not computed when not needed.
  130. #define RAW_CHECK(condition, message) \
  131. do { \
  132. if (!(condition)) { \
  133. RAW_LOG(FATAL, "Check %s failed: %s", #condition, message); \
  134. } \
  135. } while (0)
  136. // Debug versions of RAW_LOG and RAW_CHECK
  137. #ifndef NDEBUG
  138. #define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__)
  139. #define RAW_DCHECK(condition, message) RAW_CHECK(condition, message)
  140. #else // NDEBUG
  141. #define RAW_DLOG(severity, ...) \
  142. while (false) \
  143. RAW_LOG(severity, __VA_ARGS__)
  144. #define RAW_DCHECK(condition, message) \
  145. while (false) \
  146. RAW_CHECK(condition, message)
  147. #endif // NDEBUG
  148. // Stub log function used to work around for unused variable warnings when
  149. // building with STRIP_LOG > 0.
  150. static inline void RawLogStub__(int ignored, ...) {
  151. }
  152. // Helper function to implement RAW_LOG and RAW_VLOG
  153. // Logs format... at "severity" level, reporting it
  154. // as called from file:line.
  155. // This does not allocate memory or acquire locks.
  156. GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity,
  157. const char* file,
  158. int line,
  159. const char* format, ...)
  160. ;
  161. // Hack to propagate time information into this module so that
  162. // this module does not have to directly call localtime_r(),
  163. // which could allocate memory.
  164. GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs);
  165. }
  166. #endif // BASE_RAW_LOGGING_H_