summaryrefslogtreecommitdiff
blob: d08e4b17882f037d4c2132ae1e8e8832c9af01e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
https://github.com/google/glog/issues/125
https://github.com/google/glog/pull/651
https://github.com/google/glog/commit/81e0d616edeb73cbd06d6c40bc4f90593ac0c5d1

--- a/src/glog/logging.h.in
+++ b/src/glog/logging.h.in
@@ -594,6 +594,9 @@
                                             void* prefix_callback_data = NULL);
 #endif
 
+// Check if google's logging library has been initialized.
+GOOGLE_GLOG_DLL_DECL bool IsGoogleLoggingInitialized();
+
 // Shutdown google's logging library.
 GOOGLE_GLOG_DLL_DECL void ShutdownGoogleLogging();
 
--- a/src/logging_custom_prefix_unittest.cc
+++ b/src/logging_custom_prefix_unittest.cc
@@ -221,11 +221,15 @@
   LogWithLevels(0, 0, 0, 0);  // simulate "before global c-tors"
   const string early_stderr = GetCapturedTestStderr();
 
+  EXPECT_FALSE(IsGoogleLoggingInitialized());
+
   // Setting a custom prefix generator (it will use the default format so that
   // the golden outputs can be reused):
   string prefix_attacher_data = "good data";
   InitGoogleLogging(argv[0], &PrefixAttacher, static_cast<void*>(&prefix_attacher_data));
 
+  EXPECT_TRUE(IsGoogleLoggingInitialized());
+
   RunSpecifiedBenchmarks();
 
   FLAGS_logtostderr = true;
@@ -992,8 +996,10 @@
   base::SetLogger(GLOG_INFO,
                   new RecordDeletionLogger(&custom_logger_deleted,
                                            base::GetLogger(GLOG_INFO)));
+  EXPECT_TRUE(IsGoogleLoggingInitialized());
   ShutdownGoogleLogging();
   EXPECT_TRUE(custom_logger_deleted);
+  EXPECT_FALSE(IsGoogleLoggingInitialized());
 }
 
 _START_GOOGLE_NAMESPACE_
--- a/src/logging_unittest.cc
+++ b/src/logging_unittest.cc
@@ -197,8 +197,12 @@
   LogWithLevels(0, 0, 0, 0);  // simulate "before global c-tors"
   const string early_stderr = GetCapturedTestStderr();
 
+  EXPECT_FALSE(IsGoogleLoggingInitialized());
+
   InitGoogleLogging(argv[0]);
 
+  EXPECT_TRUE(IsGoogleLoggingInitialized());
+
   RunSpecifiedBenchmarks();
 
   FLAGS_logtostderr = true;
@@ -965,8 +969,10 @@
   base::SetLogger(GLOG_INFO,
                   new RecordDeletionLogger(&custom_logger_deleted,
                                            base::GetLogger(GLOG_INFO)));
+  EXPECT_TRUE(IsGoogleLoggingInitialized());
   ShutdownGoogleLogging();
   EXPECT_TRUE(custom_logger_deleted);
+  EXPECT_FALSE(IsGoogleLoggingInitialized());
 }
 
 _START_GOOGLE_NAMESPACE_
--- a/src/utilities.cc
+++ b/src/utilities.cc
@@ -62,6 +62,10 @@
 
 static const char* g_program_invocation_short_name = NULL;
 
+bool IsGoogleLoggingInitialized() {
+  return g_program_invocation_short_name != NULL;
+}
+
 _END_GOOGLE_NAMESPACE_
 
 // The following APIs are all internal.
@@ -176,10 +180,6 @@
   }
 }
 
-bool IsGoogleLoggingInitialized() {
-  return g_program_invocation_short_name != NULL;
-}
-
 #ifdef OS_WINDOWS
 struct timeval {
   long tv_sec, tv_usec;
--- a/src/utilities.h
+++ b/src/utilities.h
@@ -163,8 +163,6 @@
 
 const char* ProgramInvocationShortName();
 
-bool IsGoogleLoggingInitialized();
-
 int64 CycleClock_Now();
 
 int64 UsecToCycles(int64 usec);