The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the juce_core module of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. or without fee is hereby granted, provided that the above copyright notice and this
  7. permission notice appear in all copies.
  8. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  9. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  10. NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  11. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  12. IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. ------------------------------------------------------------------------------
  15. NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
  16. All other JUCE modules are covered by a dual GPL/commercial license, so if you are
  17. using any other modules, be sure to check that you also comply with their license.
  18. For more details, visit www.juce.com
  19. ==============================================================================
  20. */
  21. #ifndef __JUCE_LOGGER_JUCEHEADER__
  22. #define __JUCE_LOGGER_JUCEHEADER__
  23. #include "../text/juce_String.h"
  24. //==============================================================================
  25. /**
  26. Acts as an application-wide logging class.
  27. A subclass of Logger can be created and passed into the Logger::setCurrentLogger
  28. method and this will then be used by all calls to writeToLog.
  29. The logger class also contains methods for writing messages to the debugger's
  30. output stream.
  31. @see FileLogger
  32. */
  33. class JUCE_API Logger
  34. {
  35. public:
  36. //==============================================================================
  37. /** Destructor. */
  38. virtual ~Logger();
  39. //==============================================================================
  40. /** Sets the current logging class to use.
  41. Note that the object passed in will not be owned or deleted by the logger, so
  42. the caller must make sure that it is not deleted while still being used.
  43. A null pointer can be passed-in to disable any logging.
  44. */
  45. static void JUCE_CALLTYPE setCurrentLogger (Logger* newLogger) noexcept;
  46. /** Returns the current logger, or nullptr if none has been set. */
  47. static Logger* getCurrentLogger() noexcept;
  48. /** Writes a string to the current logger.
  49. This will pass the string to the logger's logMessage() method if a logger
  50. has been set.
  51. @see logMessage
  52. */
  53. static void JUCE_CALLTYPE writeToLog (const String& message);
  54. //==============================================================================
  55. /** Writes a message to the standard error stream.
  56. This can be called directly, or by using the DBG() macro in
  57. juce_PlatformDefs.h (which will avoid calling the method in non-debug builds).
  58. */
  59. static void JUCE_CALLTYPE outputDebugString (const String& text);
  60. protected:
  61. //==============================================================================
  62. Logger();
  63. /** This is overloaded by subclasses to implement custom logging behaviour.
  64. @see setCurrentLogger
  65. */
  66. virtual void logMessage (const String& message) = 0;
  67. private:
  68. static Logger* currentLogger;
  69. };
  70. #endif // __JUCE_LOGGER_JUCEHEADER__