PageRenderTime 29ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/thirdparty/breakpad/third_party/glog/src/glog/vlog_is_on.h.in

http://github.com/tomahawk-player/tomahawk
Autoconf | 129 lines | 104 code | 9 blank | 16 comment | 15 complexity | 86ac7c0fea1e7ee2a00978f6ef4ea1b1 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-3.0, GPL-2.0
  1. // Copyright (c) 1999, 2007, Google Inc.
  2. // All rights reserved.
  3. //
  4. // Redistribution and use in source and binary forms, with or without
  5. // modification, are permitted provided that the following conditions are
  6. // met:
  7. //
  8. // * Redistributions of source code must retain the above copyright
  9. // notice, this list of conditions and the following disclaimer.
  10. // * Redistributions in binary form must reproduce the above
  11. // copyright notice, this list of conditions and the following disclaimer
  12. // in the documentation and/or other materials provided with the
  13. // distribution.
  14. // * Neither the name of Google Inc. nor the names of its
  15. // contributors may be used to endorse or promote products derived from
  16. // this software without specific prior written permission.
  17. //
  18. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. //
  30. // Author: Ray Sidney and many others
  31. //
  32. // Defines the VLOG_IS_ON macro that controls the variable-verbosity
  33. // conditional logging.
  34. //
  35. // It's used by VLOG and VLOG_IF in logging.h
  36. // and by RAW_VLOG in raw_logging.h to trigger the logging.
  37. //
  38. // It can also be used directly e.g. like this:
  39. // if (VLOG_IS_ON(2)) {
  40. // // do some logging preparation and logging
  41. // // that can't be accomplished e.g. via just VLOG(2) << ...;
  42. // }
  43. //
  44. // The truth value that VLOG_IS_ON(level) returns is determined by
  45. // the three verbosity level flags:
  46. // --v=<n> Gives the default maximal active V-logging level;
  47. // 0 is the default.
  48. // Normally positive values are used for V-logging levels.
  49. // --vmodule=<str> Gives the per-module maximal V-logging levels to override
  50. // the value given by --v.
  51. // E.g. "my_module=2,foo*=3" would change the logging level
  52. // for all code in source files "my_module.*" and "foo*.*"
  53. // ("-inl" suffixes are also disregarded for this matching).
  54. //
  55. // SetVLOGLevel helper function is provided to do limited dynamic control over
  56. // V-logging by overriding the per-module settings given via --vmodule flag.
  57. //
  58. // CAVEAT: --vmodule functionality is not available in non gcc compilers.
  59. //
  60. #ifndef BASE_VLOG_IS_ON_H_
  61. #define BASE_VLOG_IS_ON_H_
  62. #include "glog/log_severity.h"
  63. // Annoying stuff for windows -- makes sure clients can import these functions
  64. #ifndef GOOGLE_GLOG_DLL_DECL
  65. # if defined(_WIN32) && !defined(__CYGWIN__)
  66. # define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
  67. # else
  68. # define GOOGLE_GLOG_DLL_DECL
  69. # endif
  70. #endif
  71. #if defined(__GNUC__)
  72. // We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
  73. // (Normally) the first time every VLOG_IS_ON(n) site is hit,
  74. // we determine what variable will dynamically control logging at this site:
  75. // it's either FLAGS_v or an appropriate internal variable
  76. // matching the current source file that represents results of
  77. // parsing of --vmodule flag and/or SetVLOGLevel calls.
  78. #define VLOG_IS_ON(verboselevel) \
  79. __extension__ \
  80. ({ static @ac_google_namespace@::int32* vlocal__ = &@ac_google_namespace@::kLogSiteUninitialized; \
  81. @ac_google_namespace@::int32 verbose_level__ = (verboselevel); \
  82. (*vlocal__ >= verbose_level__) && \
  83. ((vlocal__ != &@ac_google_namespace@::kLogSiteUninitialized) || \
  84. (@ac_google_namespace@::InitVLOG3__(&vlocal__, &FLAGS_v, \
  85. __FILE__, verbose_level__))); })
  86. #else
  87. // GNU extensions not available, so we do not support --vmodule.
  88. // Dynamic value of FLAGS_v always controls the logging level.
  89. #define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel))
  90. #endif
  91. // Set VLOG(_IS_ON) level for module_pattern to log_level.
  92. // This lets us dynamically control what is normally set by the --vmodule flag.
  93. // Returns the level that previously applied to module_pattern.
  94. // NOTE: To change the log level for VLOG(_IS_ON) sites
  95. // that have already executed after/during InitGoogleLogging,
  96. // one needs to supply the exact --vmodule pattern that applied to them.
  97. // (If no --vmodule pattern applied to them
  98. // the value of FLAGS_v will continue to control them.)
  99. extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern,
  100. int log_level);
  101. // Various declarations needed for VLOG_IS_ON above: =========================
  102. // Special value used to indicate that a VLOG_IS_ON site has not been
  103. // initialized. We make this a large value, so the common-case check
  104. // of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition
  105. // passes in such cases and InitVLOG3__ is then triggered.
  106. extern @ac_google_namespace@::int32 kLogSiteUninitialized;
  107. // Helper routine which determines the logging info for a particalur VLOG site.
  108. // site_flag is the address of the site-local pointer to the controlling
  109. // verbosity level
  110. // site_default is the default to use for *site_flag
  111. // fname is the current source file name
  112. // verbose_level is the argument to VLOG_IS_ON
  113. // We will return the return value for VLOG_IS_ON
  114. // and if possible set *site_flag appropriately.
  115. extern GOOGLE_GLOG_DLL_DECL bool InitVLOG3__(
  116. @ac_google_namespace@::int32** site_flag,
  117. @ac_google_namespace@::int32* site_default,
  118. const char* fname,
  119. @ac_google_namespace@::int32 verbose_level);
  120. #endif // BASE_VLOG_IS_ON_H_