22 #include "mongo/base/status.h"
23 #include "mongo/logger/appender.h"
24 #include "mongo/logger/log_severity.h"
25 #include "mongo/logger/logger.h"
26 #include "mongo/logger/message_log_domain.h"
27 #include "mongo/unittest/unittest.h"
35 template <
typename MessageEventEncoder>
37 friend class LogTestAppender;
40 LogTest() : _severityOld(globalLogDomain()->getMinimumLogSeverity()) {
43 MessageLogDomain::AppenderAutoPtr(
new LogTestAppender(
this)));
52 std::vector<std::string> _logLines;
58 explicit LogTestAppender(
LogTest* ltest) : _ltest(ltest) {}
59 virtual ~LogTestAppender() {}
60 virtual Status append(
const MessageLogDomain::Event& event) {
61 std::ostringstream _os;
62 if (!_encoder.encode(event, _os))
63 return Status(ErrorCodes::LogWriteFailed,
"Failed to append to LogTestAppender.");
64 _ltest->_logLines.push_back(_os.str());
70 MessageEventEncoder _encoder;
Status represents an error state or the absence thereof.
Definition: status.h:50
void clearAppenders()
Destroy all attached appenders, invalidating all handles.
Definition: log_domain-impl.h:84
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
AppenderHandle attachAppender(AppenderAutoPtr appender)
Attaches "appender" to this domain, taking ownership of it.
Definition: log_domain-impl.h:60
AppenderAutoPtr detachAppender(AppenderHandle handle)
Detaches the appender referenced by "handle" from this domain, releasing ownership of it...
Definition: log_domain-impl.h:75
Interface for sinks in a logging system.
Definition: appender.h:31
Opaque handle returned by attachAppender(), which can be subsequently passed to detachAppender() to d...
Definition: log_domain.h:61
Definition: log_test.h:36
void setMinimumLoggedSeverity(LogSeverity severity)
Sets the minimum severity of messages that should be sent to this LogDomain.
MONGO_CLIENT_API Status(MONGO_CLIENT_FUNC *saslClientAuthenticate)(DBClientWithCommands *client
Attempts to authenticate "client" using the SASL protocol.
Representation of the severity / priority of a log message.
Definition: log_severity.h:33