@@ -181,15 +181,20 @@ TEST_F(LoggingTest, Call) {
181181}
182182
183183TEST_F (LoggingTest, CallFormat) {
184- // / [Example lambda-based logging usage]
185- std::map<int , int > map{{1 , 2 }, {2 , 3 }, {3 , 4 }};
186- LOG_ERROR () << [&map](auto & out) {
187- for (const auto & [key, value] : map) {
188- out.Format (" {}={}, " , key, value);
189- }
190- };
191- // / [Example lambda-based logging usage]
192- EXPECT_EQ (" 1=2, 2=3, 3=4, " , LoggedText ());
184+ const int user_id = 42 ;
185+ std::string ip_address = " 127.0.0.1" ;
186+ std::string_view expected_result = " User 42 logged in from 127.0.0.1" ;
187+
188+ // / [Example format bad logging usage]
189+ LOG_INFO () << fmt::format (" User {} logged in from {}" , user_id, ip_address);
190+ // / [Example format bad logging usage]
191+ EXPECT_EQ (expected_result, LoggedText ());
192+ ClearLog ();
193+
194+ // / [Example format-based logging usage]
195+ LOG_INFO (" User {} logged in from {}" , user_id, ip_address);
196+ // / [Example format-based logging usage]
197+ EXPECT_EQ (expected_result, LoggedText ());
193198}
194199
195200TEST_F (LoggingTest, LoggingContainerElementFields) {
0 commit comments