|
- /*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2016 - ROLI Ltd.
-
- Permission is granted to use this software under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license/
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
- TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
- OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
- USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- OF THIS SOFTWARE.
-
- -----------------------------------------------------------------------------
-
- To release a closed-source product which uses other parts of JUCE not
- licensed under the ISC terms, commercial licenses are available: visit
- www.juce.com for more information.
-
- ==============================================================================
- */
-
- #pragma once
-
-
- //==============================================================================
- /**
- 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 FileLogger
- */
- class JUCE_API Logger
- {
- public:
- //==============================================================================
- /** Destructor. */
- virtual ~Logger();
-
- //==============================================================================
- /** 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.
- */
- static void JUCE_CALLTYPE setCurrentLogger (Logger* newLogger) noexcept;
-
- /** Returns the current logger, or nullptr if no custom logger has been set. */
- static Logger* JUCE_CALLTYPE getCurrentLogger() noexcept;
-
- /** 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 logMessage
- */
- static void JUCE_CALLTYPE writeToLog (const String& message);
-
-
- //==============================================================================
- /** 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).
- */
- static void JUCE_CALLTYPE outputDebugString (const String& text);
-
-
- protected:
- //==============================================================================
- Logger();
-
- /** This is overloaded by subclasses to implement custom logging behaviour.
- @see setCurrentLogger
- */
- virtual void logMessage (const String& message) = 0;
-
- private:
- static Logger* currentLogger;
- };
|