44#include < string>
55#include < utility>
66
7+ #include " absl/log/log.h"
8+
79namespace bar {
810std::vector<std::string> stringVectorOutput (int level) {
9- std::cout << " [" << level << " ] Enter " << __func__ << " ()" << std::endl;
11+ LOG (INFO) << " [" << level << " ] Enter " << __func__ << " ()" << std::endl;
1012 std::vector<std::string> result (level, std::to_string (level));
11- std::cout << " [" << level << " ] Exit " << __func__ << " ()" << std::endl;
13+ LOG (INFO) << " [" << level << " ] Exit " << __func__ << " ()" << std::endl;
1214 return result;
1315}
1416
1517int stringVectorInput (std::vector<std::string> data) {
16- std::cout << " Enter " << __func__ << " ()" << std::endl;
17- std::cout << " {" ;
18+ LOG (INFO) << " Enter " << __func__ << " ()" << std::endl;
19+ LOG (INFO) << " {" ;
1820 for (const auto & item : data) {
19- std::cout << item << " , " ;
21+ LOG (INFO) << item << " , " ;
2022 }
21- std::cout << " }" << std::endl;
22- std::cout << " Exit " << __func__ << " ()" << std::endl;
23+ LOG (INFO) << " }" << std::endl;
24+ LOG (INFO) << " Exit " << __func__ << " ()" << std::endl;
2325 return data.size ();
2426}
2527
2628int stringVectorRefInput (const std::vector<std::string>& data) {
27- std::cout << " Enter " << __func__ << " ()" << std::endl;
28- std::cout << " {" ;
29+ LOG (INFO) << " Enter " << __func__ << " ()" << std::endl;
30+ LOG (INFO) << " {" ;
2931 for (const auto & item : data) {
30- std::cout << item << " , " ;
32+ LOG (INFO) << item << " , " ;
3133 }
32- std::cout << " }" << std::endl;
33- std::cout << " Exit " << __func__ << " ()" << std::endl;
34+ LOG (INFO) << " }" << std::endl;
35+ LOG (INFO) << " Exit " << __func__ << " ()" << std::endl;
3436 return data.size ();
3537}
3638
3739std::vector<std::vector<std::string>> stringJaggedArrayOutput (int level) {
38- std::cout << " [" << level << " ] Enter " << __func__ << " ()" << std::endl;
40+ LOG (INFO) << " [" << level << " ] Enter " << __func__ << " ()" << std::endl;
3941 std::vector<std::vector<std::string>> result;
4042 result.reserve (level);
4143 for (int i = 1 ; i <= level; ++i) {
4244 result.emplace_back (std::vector<std::string>(i, std::to_string (i)));
4345 }
44- std::cout << " [" << level << " ] Exit " << __func__ << " ()" << std::endl;
46+ LOG (INFO) << " [" << level << " ] Exit " << __func__ << " ()" << std::endl;
4547 return result;
4648}
4749
4850int stringJaggedArrayInput (std::vector<std::vector<std::string>> data) {
49- std::cout << " Enter " << __func__ << " ()" << std::endl;
50- std::cout << " {" ;
51+ LOG (INFO) << " Enter " << __func__ << " ()" << std::endl;
52+ LOG (INFO) << " {" ;
5153 for (const auto & inner : data) {
52- std::cout << " {" ;
54+ LOG (INFO) << " {" ;
5355 for (const auto & item : inner) {
54- std::cout << item << " , " ;
56+ LOG (INFO) << item << " , " ;
5557 }
56- std::cout << " }, " ;
58+ LOG (INFO) << " }, " ;
5759 }
58- std::cout << " }" << std::endl;
59- std::cout << " Exit " << __func__ << " ()" << std::endl;
60+ LOG (INFO) << " }" << std::endl;
61+ LOG (INFO) << " Exit " << __func__ << " ()" << std::endl;
6062 return data.size ();
6163}
6264
6365int stringJaggedArrayRefInput (const std::vector<std::vector<std::string>>& data) {
64- std::cout << " Enter " << __func__ << " ()" << std::endl;
65- std::cout << " {" ;
66+ LOG (INFO) << " Enter " << __func__ << " ()" << std::endl;
67+ LOG (INFO) << " {" ;
6668 for (const auto & inner : data) {
67- std::cout << " {" ;
69+ LOG (INFO) << " {" ;
6870 for (const auto & item : inner) {
69- std::cout << item << " , " ;
71+ LOG (INFO) << item << " , " ;
7072 }
71- std::cout << " }, " ;
73+ LOG (INFO) << " }, " ;
7274 }
73- std::cout << " }" << std::endl;
74- std::cout << " Exit " << __func__ << " ()" << std::endl;
75+ LOG (INFO) << " }" << std::endl;
76+ LOG (INFO) << " Exit " << __func__ << " ()" << std::endl;
7577 return data.size ();
7678}
7779
7880std::vector<std::pair<int , int >> pairVectorOutput (int level) {
79- std::cout << " [" << level << " ] Enter " << __func__ << " ()" << std::endl;
81+ LOG (INFO) << " [" << level << " ] Enter " << __func__ << " ()" << std::endl;
8082 std::vector<std::pair<int , int >> result (level, std::make_pair (level, level));
81- std::cout << " [" << level << " ] Exit " << __func__ << " ()" << std::endl;
83+ LOG (INFO) << " [" << level << " ] Exit " << __func__ << " ()" << std::endl;
8284 return result;
8385}
8486
8587int pairVectorInput (std::vector<std::pair<int , int >> data) {
86- std::cout << " Enter " << __func__ << " ()" << std::endl;
87- std::cout << " {" ;
88+ LOG (INFO) << " Enter " << __func__ << " ()" << std::endl;
89+ LOG (INFO) << " {" ;
8890 for (const auto & item : data) {
89- std::cout << " [" << item.first << " ," << item.second << " ], " ;
91+ LOG (INFO) << " [" << item.first << " ," << item.second << " ], " ;
9092 }
91- std::cout << " }" << std::endl;
92- std::cout << " Exit " << __func__ << " ()" << std::endl;
93+ LOG (INFO) << " }" << std::endl;
94+ LOG (INFO) << " Exit " << __func__ << " ()" << std::endl;
9395 return data.size ();
9496}
9597
9698int pairVectorRefInput (const std::vector<std::pair<int , int >>& data) {
97- std::cout << " Enter " << __func__ << " ()" << std::endl;
98- std::cout << " {" ;
99+ LOG (INFO) << " Enter " << __func__ << " ()" << std::endl;
100+ LOG (INFO) << " {" ;
99101 for (const auto & item : data) {
100- std::cout << " [" << item.first << " ," << item.second << " ], " ;
102+ LOG (INFO) << " [" << item.first << " ," << item.second << " ], " ;
101103 }
102- std::cout << " }" << std::endl;
103- std::cout << " Exit " << __func__ << " ()" << std::endl;
104+ LOG (INFO) << " }" << std::endl;
105+ LOG (INFO) << " Exit " << __func__ << " ()" << std::endl;
104106 return data.size ();
105107}
106108
107109std::vector<std::vector<std::pair<int , int >>> pairJaggedArrayOutput (int level) {
108- std::cout << " [" << level << " ] Enter " << __func__ << " ()" << std::endl;
110+ LOG (INFO) << " [" << level << " ] Enter " << __func__ << " ()" << std::endl;
109111 std::vector<std::vector<std::pair<int , int >>> result;
110112 result.reserve (level);
111113 for (int i = 1 ; i <= level; ++i) {
112114 result.emplace_back (std::vector<std::pair<int , int >>(i, std::make_pair (i, i)));
113115 }
114- std::cout << " [" << level << " ] Exit " << __func__ << " ()" << std::endl;
116+ LOG (INFO) << " [" << level << " ] Exit " << __func__ << " ()" << std::endl;
115117 return result;
116118}
117119
118120int pairJaggedArrayInput (std::vector<std::vector<std::pair<int , int >>> data) {
119- std::cout << " Enter " << __func__ << " ()" << std::endl;
120- std::cout << " {" ;
121+ LOG (INFO) << " Enter " << __func__ << " ()" << std::endl;
122+ LOG (INFO) << " {" ;
121123 for (const auto & inner : data) {
122- std::cout << " {" ;
124+ LOG (INFO) << " {" ;
123125 for (const auto & item : inner) {
124- std::cout << " [" << item.first << " ," << item.second << " ], " ;
126+ LOG (INFO) << " [" << item.first << " ," << item.second << " ], " ;
125127 }
126- std::cout << " }, " ;
128+ LOG (INFO) << " }, " ;
127129 }
128- std::cout << " }" << std::endl;
129- std::cout << " Exit " << __func__ << " ()" << std::endl;
130+ LOG (INFO) << " }" << std::endl;
131+ LOG (INFO) << " Exit " << __func__ << " ()" << std::endl;
130132 return data.size ();
131133}
132134
133135int pairJaggedArrayRefInput (const std::vector<std::vector<std::pair<int , int >>>& data) {
134- std::cout << " Enter " << __func__ << " ()" << std::endl;
135- std::cout << " {" ;
136+ LOG (INFO) << " Enter " << __func__ << " ()" << std::endl;
137+ LOG (INFO) << " {" ;
136138 for (const auto & inner : data) {
137- std::cout << " {" ;
139+ LOG (INFO) << " {" ;
138140 for (const auto & item : inner) {
139- std::cout << " [" << item.first << " ," << item.second << " ], " ;
141+ LOG (INFO) << " [" << item.first << " ," << item.second << " ], " ;
140142 }
141- std::cout << " }, " ;
143+ LOG (INFO) << " }, " ;
142144 }
143- std::cout << " }" << std::endl;
144- std::cout << " Exit " << __func__ << " ()" << std::endl;
145+ LOG (INFO) << " }" << std::endl;
146+ LOG (INFO) << " Exit " << __func__ << " ()" << std::endl;
145147 return data.size ();
146148}
147149
148150void freeFunction (int level) {
149- std::cout << " [" << level << " ] Enter " << __func__ << " (int)" << std::endl;
150- std::cout << " [" << level << " ] Exit " << __func__ << " (int)" << std::endl;
151+ LOG (INFO) << " [" << level << " ] Enter " << __func__ << " (int)" << std::endl;
152+ LOG (INFO) << " [" << level << " ] Exit " << __func__ << " (int)" << std::endl;
151153}
152154
153155void freeFunction (int64_t level) {
154- std::cout << " [" << level << " ] Enter " << __func__ << " (int64_t)" << std::endl;
155- std::cout << " [" << level << " ] Exit " << __func__ << " (int64_t)" << std::endl;
156+ LOG (INFO) << " [" << level << " ] Enter " << __func__ << " (int64_t)" << std::endl;
157+ LOG (INFO) << " [" << level << " ] Exit " << __func__ << " (int64_t)" << std::endl;
156158}
157159
158160void Bar::staticFunction (int level) {
159- std::cout << " [" << level << " ] Enter " << __func__ << " (int)" << std::endl;
161+ LOG (INFO) << " [" << level << " ] Enter " << __func__ << " (int)" << std::endl;
160162 freeFunction (level + 1 );
161- std::cout << " [" << level << " ] Exit " << __func__ << " (int)" << std::endl;
163+ LOG (INFO) << " [" << level << " ] Exit " << __func__ << " (int)" << std::endl;
162164}
163165
164166void Bar::staticFunction (int64_t level) {
165- std::cout << " [" << level << " ] Enter " << __func__ << " (int64_t)" << std::endl;
167+ LOG (INFO) << " [" << level << " ] Enter " << __func__ << " (int64_t)" << std::endl;
166168 freeFunction (level + 1 );
167- std::cout << " [" << level << " ] Exit " << __func__ << " (int64_t)" << std::endl;
169+ LOG (INFO) << " [" << level << " ] Exit " << __func__ << " (int64_t)" << std::endl;
168170}
169171
170172int Bar::getInt () const {
@@ -187,4 +189,12 @@ std::string Bar::operator()() const {
187189 return std::string{" \" Bar\" :{\" int\" :" } + std::to_string (_intValue) +
188190 " ,\" int64\" :" + std::to_string (_int64Value) + " }" ;
189191}
192+
193+ namespace {
194+ void * kVar = [] {
195+ std::cerr << " kBar" << std::endl;
196+ return nullptr ;
197+ }();
198+ } // namespace
199+
190200} // namespace bar
0 commit comments