| Version: 3.2.5

Public Member Functions | List of all members
wxLogNull Class Reference
Class List by Category » Logging

`#include <wx/log.h>`

## Detailed Description

This class allows you to temporarily suspend logging.

All calls to the log functions during the life time of an object of this class are just ignored.

In particular, it can be used to suppress the log messages given by wxWidgets itself but it should be noted that it is rarely the best way to cope with this problem as all log messages are suppressed, even if they indicate a completely different error than the one the programmer wanted to suppress.

For instance, the example of the overview:

wxFile file;
// wxFile.Open() normally complains if file can't be opened, we don't want it
{
wxLogNull logNo;
if ( !file.Open("bar") )
... process error ourselves ...
} // ~wxLogNull called, old log sink restored
wxLogMessage("..."); // ok
wxFile
A wxFile performs raw file I/O.
Definition: file.h:169
wxFile::Open
bool Open(const wxString &filename, wxFile::OpenMode mode=wxFile::read, int access=wxS_DEFAULT)
Opens the file, returning true if successful.
wxLogNull
This class allows you to temporarily suspend logging.
Definition: log.h:943
wxLogMessage
void wxLogMessage(const char *formatString,...)
For all normal, informational messages.

would be better written as:

wxFile file;
// don't try to open file if it doesn't exist, we are prepared to deal with
// this ourselves - but all other errors are not expected
if ( wxFile::Exists("bar") )
{
// gives an error message if the file couldn't be opened
file.Open("bar");
}
else
{
...
}
wxFile::Exists
static bool Exists(const wxString &filename)
Returns true if the given name specifies an existing regular file (not a directory or a link).

##

Library: wxBase
Category: Logging

## Public Member Functions

| wxLogNull ()
| Suspends logging. More...
| ~wxLogNull ()
| Resumes logging. More...

## Constructor & Destructor Documentation

## ◆ wxLogNull()

wxLogNull::wxLogNull | ( |  | ) |

Suspends logging.

## ◆ ~wxLogNull()

wxLogNull::~wxLogNull | ( |  | ) |

Resumes logging.