Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::base::NullLogEntryWriter Class Reference

A NullLogEntryWriter can be used completely disable all logging programmatically as long as it exists. More...

#include "nulllogentrywriter.h"

Inheritance diagram for ion::base::NullLogEntryWriter:
Collaboration diagram for ion::base::NullLogEntryWriter:

Public Member Functions

 NullLogEntryWriter ()
 
 ~NullLogEntryWriter () override
 
void Write (port::LogSeverity severity, const std::string &message) override
 LogEntryWriter impl. More...
 

Protected Member Functions

const char * GetSeverityName (LogSeverity severity) const
 Convenient way to map a severity-code to a printable represenation. More...
 

Detailed Description

A NullLogEntryWriter can be used completely disable all logging programmatically as long as it exists.

In this way it is similar to a LogChecker, but does not actually send log messages anywhere. Note that this does NOT prevent FATAL, DFATAL, or DCHECKs from calling the currently installed break handler.

You can disable logging for a scope like this: { NullLogEntryWriter null_logger; ... ///< Very verbose code. } // Old writer is restored when the null logger passes out of scope.

Alternatively, managing the life of the instance can disable logging for longer periods, for example: #if ION_PRODUCTION std::unique_ptr<NullLogEntryWriter> null_logger(new NullLogEntryWriter); #endif could be used to completely disable logging in an application when building for production mode.

Definition at line 49 of file nulllogentrywriter.h.

Constructor & Destructor Documentation

ion::base::NullLogEntryWriter::NullLogEntryWriter ( )
inline

Definition at line 51 of file nulllogentrywriter.h.

References ion::base::SetLogEntryWriter().

ion::base::NullLogEntryWriter::~NullLogEntryWriter ( )
inlineoverride

Definition at line 54 of file nulllogentrywriter.h.

References ion::base::SetLogEntryWriter().

Member Function Documentation

const char * ion::port::LogEntryWriter::GetSeverityName ( LogSeverity  severity) const
protectedinherited

Convenient way to map a severity-code to a printable represenation.

Maps a Severity code to a name for printing.

Definition at line 24 of file logging.cc.

References ion::port::DFATAL, ion::port::ERROR, ion::port::FATAL, ion::port::INFO, and ion::port::WARNING.

Referenced by ion::base::LogChecker::Write().

void ion::base::NullLogEntryWriter::Write ( port::LogSeverity  severity,
const std::string &  message 
)
inlineoverridevirtual

LogEntryWriter impl.

Implements ion::port::LogEntryWriter.

Definition at line 60 of file nulllogentrywriter.h.


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