JUCE  v5.1.1-3-g1a0b28c73
JUCE API
Logger Class Referenceabstract

Acts as an application-wide logging class. More...

#include <juce_Logger.h>

Inheritance diagram for Logger:
Collaboration diagram for Logger:

Public Member Functions

virtual ~Logger ()
 Destructor. More...
 

Static Public Member Functions

static LoggergetCurrentLogger () noexcept
 Returns the current logger, or nullptr if no custom logger has been set. More...
 
static void outputDebugString (const String &text)
 Writes a message to the standard error stream. More...
 
static void setCurrentLogger (Logger *newLogger) noexcept
 Sets the current logging class to use. More...
 
static void writeToLog (const String &message)
 Writes a string to the current logger. More...
 

Protected Member Functions

 Logger ()
 
virtual void logMessage (const String &message)=0
 This is overloaded by subclasses to implement custom logging behaviour. More...
 

Static Private Attributes

static LoggercurrentLogger
 

Detailed Description

Acts as an application-wide logging class.

A subclass of Logger can be created and passed into the Logger::setCurrentLogger method and this will then be used by all calls to writeToLog.

The logger class also contains methods for writing messages to the debugger's output stream.

See also
FileLogger

Constructor & Destructor Documentation

◆ ~Logger()

virtual Logger::~Logger ( )
virtual

Destructor.

◆ Logger()

Logger::Logger ( )
protected

Member Function Documentation

◆ getCurrentLogger()

static Logger* Logger::getCurrentLogger ( )
staticnoexcept

Returns the current logger, or nullptr if no custom logger has been set.

◆ logMessage()

virtual void Logger::logMessage ( const String message)
protectedpure virtual

This is overloaded by subclasses to implement custom logging behaviour.

See also
setCurrentLogger

Implemented in FileLogger.

Referenced by FileLogger::getLogFile().

◆ outputDebugString()

static void Logger::outputDebugString ( const String text)
static

Writes a message to the standard error stream.

This can be called directly, or by using the DBG() macro in juce_PlatformDefs.h (which will avoid calling the method in non-debug builds).

◆ setCurrentLogger()

static void Logger::setCurrentLogger ( Logger newLogger)
staticnoexcept

Sets the current logging class to use.

Note that the object passed in will not be owned or deleted by the logger, so the caller must make sure that it is not deleted while still being used. A null pointer can be passed-in to reset the system to the default logger.

◆ writeToLog()

static void Logger::writeToLog ( const String message)
static

Writes a string to the current logger.

This will pass the string to the logger's logMessage() method if a logger has been set.

See also
logMessage

Member Data Documentation

◆ currentLogger

Logger* Logger::currentLogger
staticprivate

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