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.

96 lines
3.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. #pragma once
  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 reset the system to the default logger.
  44. */
  45. static void JUCE_CALLTYPE setCurrentLogger (Logger* newLogger) noexcept;
  46. /** Returns the current logger, or nullptr if no custom logger has been set. */
  47. static Logger* JUCE_CALLTYPE 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. };