Lines Matching full:log
16 #include "absl/log/log_sink.h"
21 #include "absl/log/internal/test_actions.h"
22 #include "absl/log/internal/test_helpers.h"
23 #include "absl/log/internal/test_matchers.h"
24 #include "absl/log/log.h"
25 #include "absl/log/log_sink_registry.h"
26 #include "absl/log/scoped_mock_log.h"
43 // Tests for global log sink registration.
50 EXPECT_CALL(test_sink, Log(_, _, "hello world")).Times(0); in TEST()
51 EXPECT_CALL(test_sink, Log(absl::LogSeverity::kInfo, __FILE__, "Test : 42")); in TEST()
53 Log(absl::LogSeverity::kWarning, __FILE__, "Danger ahead")); in TEST()
55 Log(absl::LogSeverity::kError, __FILE__, "This is an error")); in TEST()
57 LOG(INFO) << "hello world"; in TEST()
60 LOG(INFO) << "Test : " << 42; in TEST()
61 LOG(WARNING) << "Danger" << ' ' << "ahead"; in TEST()
62 LOG(ERROR) << "This is an error"; in TEST()
65 LOG(INFO) << "Goodby world"; in TEST()
73 EXPECT_CALL(test_sink1, Log(absl::LogSeverity::kInfo, _, "First")).Times(1); in TEST()
74 EXPECT_CALL(test_sink2, Log(absl::LogSeverity::kInfo, _, "First")).Times(0); in TEST()
76 EXPECT_CALL(test_sink1, Log(absl::LogSeverity::kInfo, _, "Second")).Times(1); in TEST()
77 EXPECT_CALL(test_sink2, Log(absl::LogSeverity::kInfo, _, "Second")).Times(1); in TEST()
79 EXPECT_CALL(test_sink1, Log(absl::LogSeverity::kInfo, _, "Third")).Times(0); in TEST()
80 EXPECT_CALL(test_sink2, Log(absl::LogSeverity::kInfo, _, "Third")).Times(1); in TEST()
82 LOG(INFO) << "Before first"; in TEST()
85 LOG(INFO) << "First"; in TEST()
88 LOG(INFO) << "Second"; in TEST()
91 LOG(INFO) << "Third"; in TEST()
94 LOG(INFO) << "Fourth"; in TEST()
104 HasSubstr("Duplicate log sinks")); in TEST()
113 HasSubstr("Mismatched log sink")); in TEST()
116 // Tests for log sink semantic.
133 void Send(const absl::LogEntry&) override { LOG(FATAL) << "goodbye world"; } in TEST()
137 EXPECT_EXIT({ LOG(INFO).ToSinkAlso(&sink) << "hello world"; }, DiedOfFatal, in TEST()
141 // Tests for explicit log sink redirection.
147 EXPECT_CALL(test_sink, Log(_, _, "hello world")); in TEST()
148 EXPECT_CALL(another_sink, Log(_, _, "hello world")); in TEST()
151 LOG(INFO).ToSinkAlso(&another_sink.UseAsLocalSink()) << "hello world"; in TEST()
156 EXPECT_CALL(another_sink, Log(_, _, "hello world")); in TEST()
157 LOG(INFO).ToSinkOnly(&another_sink.UseAsLocalSink()) << "hello world"; in TEST()
167 EXPECT_CALL(sink3, Log(_, _, "hello world")); in TEST()
168 EXPECT_CALL(sink4, Log(_, _, "hello world")); in TEST()
169 EXPECT_CALL(sink5, Log(_, _, "hello world")); in TEST()
171 LOG(INFO) in TEST()
196 LOG(LEVEL(severity_)) << "The log is coming from *inside the sink*."; in Send()
199 LOG(LEVEL(severity_)).ToSinkAlso(sink_) in Send()
200 << "The log is coming from *inside the sink*."; in Send()
203 LOG(LEVEL(severity_)).ToSinkOnly(sink_) in Send()
204 << "The log is coming from *inside the sink*."; in Send()
207 LOG(FATAL) << "Invalid mode " << static_cast<int>(mode_); in Send()
220 LOG(LEVEL(severity)) << to_log; in LogAndReturn()
229 EXPECT_CALL(test_sink, Log(absl::LogSeverity::kInfo, _, "hello")); in TEST_F()
230 EXPECT_CALL(test_sink, Log(absl::LogSeverity::kInfo, _, "world")); in TEST_F()
231 EXPECT_CALL(test_sink, Log(absl::LogSeverity::kWarning, _, "danger")); in TEST_F()
232 EXPECT_CALL(test_sink, Log(absl::LogSeverity::kInfo, _, "here")); in TEST_F()
235 LOG(INFO) << LogAndReturn(absl::LogSeverity::kInfo, "hello", "world"); in TEST_F()
236 LOG(INFO) << LogAndReturn(absl::LogSeverity::kWarning, "danger", "here"); in TEST_F()
242 EXPECT_CALL(test_sink, Log(_, _, "hello world")); in TEST_F()
246 LOG(INFO) << "hello world"; in TEST_F()
253 EXPECT_CALL(test_sink, Log(_, _, "hello world")); in TEST_F()
255 Log(_, _, "The log is coming from *inside the sink*.")); in TEST_F()
258 LOG(INFO).ToSinkAlso(&reentrant_sink) << "hello world"; in TEST_F()
264 EXPECT_CALL(test_sink, Log(_, _, "hello world")); in TEST_F()
266 // second time log statement is run we are in "ThreadIsLogging" mode and all in TEST_F()
267 // the log statements are redirected into stderr. in TEST_F()
269 Log(_, _, "The log is coming from *inside the sink*.")); in TEST_F()
273 LOG(INFO).ToSinkAlso(&reentrant_sink) << "hello world"; in TEST_F()
281 Log(_, _, "The log is coming from *inside the sink*.")); in TEST_F()
284 LOG(INFO).ToSinkOnly(&reentrant_sink) << "hello world"; in TEST_F()
291 Log(_, _, "The log is coming from *inside the sink*.")); in TEST_F()
295 LOG(INFO).ToSinkOnly(&reentrant_sink) << "hello world"; in TEST_F()
306 EXPECT_CALL(test_sink, Log) in TEST_F()
309 EXPECT_CALL(test_sink, Log(_, _, "hello")) in TEST_F()
313 LOG(INFO) << LogAndReturn(absl::LogSeverity::kFatal, "hello", "world"); in TEST_F()
323 EXPECT_CALL(test_sink, Log) in TEST_F()
326 EXPECT_CALL(test_sink, Log(_, _, "hello world")) in TEST_F()
331 LOG(INFO) << "hello world"; in TEST_F()
343 EXPECT_CALL(test_sink, Log) in TEST_F()
346 EXPECT_CALL(test_sink, Log(_, _, "hello world")) in TEST_F()
349 Log(_, _, "The log is coming from *inside the sink*.")) in TEST_F()
353 LOG(INFO).ToSinkAlso(&reentrant_sink) << "hello world"; in TEST_F()
363 EXPECT_CALL(test_sink, Log) in TEST_F()
366 EXPECT_CALL(test_sink, Log(_, _, "hello world")) in TEST_F()
369 Log(_, _, "The log is coming from *inside the sink*.")) in TEST_F()
374 LOG(INFO).ToSinkAlso(&reentrant_sink) << "hello world"; in TEST_F()
385 EXPECT_CALL(test_sink, Log) in TEST_F()
389 Log(_, _, "The log is coming from *inside the sink*.")) in TEST_F()
393 LOG(INFO).ToSinkOnly(&reentrant_sink) << "hello world"; in TEST_F()
403 EXPECT_CALL(test_sink, Log) in TEST_F()
407 Log(_, _, "The log is coming from *inside the sink*.")) in TEST_F()
412 LOG(INFO).ToSinkOnly(&reentrant_sink) << "hello world"; in TEST_F()