Audacity 3.2.0
AudacityLogger.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 AudacityLogger.h
6
7 Dominic Mazzoni
8
9**********************************************************************/
10
11#ifndef __AUDACITY_LOGGER__
12#define __AUDACITY_LOGGER__
13
14#include <wx/log.h> // to inherit
15#include <wx/event.h> // to inherit wxEvtHandler
16
17class wxFrame;
18class wxTextCtrl;
19
20class FILES_API AudacityLogger final : public wxEvtHandler,
21 public wxLog
22{
23 public:
24
25 ~AudacityLogger() override;
26
27 // Get the singleton instance or null
28 static AudacityLogger *Get();
29
30 bool SaveLog(const wxString &fileName) const;
31 bool ClearLog();
32
34
35 wxString GetLog(int count = 0);
36
38 const wxString &GetBuffer() const { return mBuffer; }
39
40 void Flush() override;
41
43
45 using Listener = std::function< bool() >;
46
48 Listener SetListener(Listener listener);
49
50protected:
51 void DoLogText(const wxString & msg) override;
52
53 private:
55
57 wxString mBuffer;
59};
60
61#endif
AudacityLogger is a thread-safe logger class.
~AudacityLogger() override
const wxString & GetBuffer() const
Get all the accumulated text since program start or last ClearLog()
wxString mBuffer
std::function< bool() > Listener
Type of function called by Flush.
Listener mListener
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:194