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