Initial windows support. Now we don't have the stacktrace and several unittests.
[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 1999, 2007 Google Inc. All Rights Reserved.
6 // Author: Ray Sidney and many others
7 //
8 // Defines the VLOG_IS_ON macro that controls the variable-verbosity
9 // conditional logging.
10 //
11 // It's used by VLOG and VLOG_IF in logging.h
12 // and by RAW_VLOG in raw_logging.h to trigger the logging.
13 //
14 // It can also be used directly e.g. like this:
15 //   if (VLOG_IS_ON(2)) {
16 //     // do some logging preparation and logging
17 //     // that can't be accomplished e.g. via just VLOG(2) << ...;
18 //   }
19 //
20 // The truth value that VLOG_IS_ON(level) returns is determined by 
21 // the three verbosity level flags:
22 //   --v=<n>  Gives the default maximal active V-logging level;
23 //            0 is the default.
24 //            Normally positive values are used for V-logging levels.
25 //   --vmodule=<str>  Gives the per-module maximal V-logging levels to override
26 //                    the value given by --v.
27 //                    E.g. "my_module=2,foo*=3" would change the logging level
28 //                    for all code in source files "my_module.*" and "foo*.*"
29 //                    ("-inl" suffixes are also disregarded for this matching).
30 //
31 // SetVLOGLevel helper function is provided to do limited dynamic control over
32 // V-logging by overriding the per-module settings given via --vmodule flag.
33 //
34 // CAVEAT: --vmodule functionality is not available in non gcc compilers.
35 //
36
37 #ifndef BASE_VLOG_IS_ON_H_
38 #define BASE_VLOG_IS_ON_H_
39
40 #include "glog/log_severity.h"
41
42 // Annoying stuff for windows -- makes sure clients can import these functions
43 #ifndef GOOGLE_GLOG_DLL_DECL
44 # ifdef _WIN32
45 #   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
46 # else
47 #   define GOOGLE_GLOG_DLL_DECL
48 # endif
49 #endif
50
51 #if defined(__GNUC__)
52 // We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
53 // (Normally) the first time every VLOG_IS_ON(n) site is hit,
54 // we determine what variable will dynamically control logging at this site:
55 // it's either FLAGS_v or an appropriate internal variable
56 // matching the current source file that represents results of
57 // parsing of --vmodule flag and/or SetVLOGLevel calls.
58 #define VLOG_IS_ON(verboselevel)                                \
59   ({ static google::int32* vlocal__ = &google::kLogSiteUninitialized;           \
60      google::int32 verbose_level__ = (verboselevel);                    \
61      (*vlocal__ >= verbose_level__) &&                          \
62      ((vlocal__ != &google::kLogSiteUninitialized) ||                   \
63       (google::InitVLOG3__(&vlocal__, &FLAGS_v,                         \
64                    __FILE__, verbose_level__))); })
65 #else
66 // GNU extensions not available, so we do not support --vmodule.
67 // Dynamic value of FLAGS_v always controls the logging level.
68 #define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel))
69 #endif
70
71 // Set VLOG(_IS_ON) level for module_pattern to log_level.
72 // This lets us dynamically control what is normally set by the --vmodule flag.
73 // Returns the level that previously applied to module_pattern.
74 // NOTE: To change the log level for VLOG(_IS_ON) sites
75 //       that have already executed after/during InitGoogleLogging,
76 //       one needs to supply the exact --vmodule pattern that applied to them.
77 //       (If no --vmodule pattern applied to them
78 //       the value of FLAGS_v will continue to control them.)
79 extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern,
80                                              int log_level);
81
82 // Various declarations needed for VLOG_IS_ON above: =========================
83
84 // Special value used to indicate that a VLOG_IS_ON site has not been
85 // initialized.  We make this a large value, so the common-case check
86 // of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition
87 // passes in such cases and InitVLOG3__ is then triggered.
88 extern google::int32 kLogSiteUninitialized;
89
90 // Helper routine which determines the logging info for a particalur VLOG site.
91 //   site_flag     is the address of the site-local pointer to the controlling
92 //                 verbosity level
93 //   site_default  is the default to use for *site_flag
94 //   fname         is the current source file name
95 //   verbose_level is the argument to VLOG_IS_ON
96 // We will return the return value for VLOG_IS_ON
97 // and if possible set *site_flag appropriately.
98 extern GOOGLE_GLOG_DLL_DECL bool InitVLOG3__(
99     google::int32** site_flag,
100     google::int32* site_default,
101     const char* fname,
102     google::int32 verbose_level);
103
104 #endif  // BASE_VLOG_IS_ON_H_