MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
mongo::logger::LogDomain< E > Class Template Reference

Logging domain for events of type E. More...

#include <log_domain.h>

+ Inheritance diagram for mongo::logger::LogDomain< E >:

Classes

class  AppenderHandle
 Opaque handle returned by attachAppender(), which can be subsequently passed to detachAppender() to detach an appender from an instance of LogDomain. More...
 

Public Member Functions

Status append (const Event &event)
 Receives an event for logging, calling append(event) on all attached appenders.
 
bool getAbortOnFailure () const
 Gets the state of the abortOnFailure flag.
 
void setAbortOnFailure (bool abortOnFailure)
 Sets the state of the abortOnFailure flag.
 
AppenderHandle attachAppender (AppenderAutoPtr appender)
 Attaches "appender" to this domain, taking ownership of it.
 
AppenderAutoPtr detachAppender (AppenderHandle handle)
 Detaches the appender referenced by "handle" from this domain, releasing ownership of it.
 
void clearAppenders ()
 Destroy all attached appenders, invalidating all handles.
 

Detailed Description

template<typename E>
class mongo::logger::LogDomain< E >

Logging domain for events of type E.

A logging domain consists of a set of Appenders.

TODO: The severity doesn't seem to apply for auditing, maybe it only belongs on the MessageLogManager? We don't really have multiple tunable logging domains, right now. Other than the global domain, shouldLog doesn't matter.

Usage: Configure the log domain in a single threaded context, using attachAppender, detachAppender and clearAppenders(). The domain takes ownership of any attached appender, returning an AppenderHandle for each attached appender. That handle may be used later to detach the appender, causing the domain to release ownership of it. Mostly, this attach/detach behavior is useful in testing, since you do not want to change the appenders of a domain that is currently receiving append() calls.

Once you've configured the domain, call append() from potentially many threads, to add log messages.

Member Function Documentation

◆ append()

template<typename E >
Status mongo::logger::LogDomain< E >::append ( const Event &  event)

Receives an event for logging, calling append(event) on all attached appenders.

If any appender fails, the behavior is determined by the abortOnFailure flag: *If abortOnFailure is set, ::abort() is immediately called. *If abortOnFailure is not set, the error is returned and no further appenders are called.

◆ attachAppender()

template<typename E >
LogDomain< E >::AppenderHandle mongo::logger::LogDomain< E >::attachAppender ( AppenderAutoPtr  appender)

Attaches "appender" to this domain, taking ownership of it.

Returns a handle that may be used later to detach this appender.

◆ detachAppender()

template<typename E >
LogDomain< E >::AppenderAutoPtr mongo::logger::LogDomain< E >::detachAppender ( AppenderHandle  handle)

Detaches the appender referenced by "handle" from this domain, releasing ownership of it.

Returns an auto_ptr to the handler to the caller, who is now responsible for its deletion. Caller should consider "handle" is invalid after this call.


The documentation for this class was generated from the following files: