Code::Blocks  SVN r11506
logger.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  */
5 
6 #ifndef LOGGER_H
7 #define LOGGER_H
8 
9 #include "prep.h"
10 #include <wx/string.h>
11 #include "settings.h" // DLLIMPORT
12 
13 class wxMenu;
14 class wxWindow;
15 
16 namespace
17 {
18  static wxString temp_string(_T('\0'), 250);
19  static wxString newline_string(_T("\n"));
20 }
21 
24 {
25 public:
26  /*
27  * The ubiquitous, standard log levels to use are: info, warning, error, critical
28  *
29  * info - I'm telling you, but you probably won't bother reading anyway.
30  * warning - You should know about this. I'm telling you now, so you can't sue me later.
31  * error - Something failed, but the world is not going to end.
32  * critical - Something failed, and it hit you right in the eye. It really hurts, you have to do something.
33  *
34  * Other log levels are for special uses and may have side effects that you don't know about,
35  * and they may not work like expected under the specific conditions they run in... don't use them.
36  */
37  enum level { caption, info, warning, success, error, critical, failure, pagetitle, spacer, asterisk };
38  enum { num_levels = asterisk +1 };
39 
40  struct Feature
41  {
42  enum Enum
43  {
44  IsWrappable = 0,
47  Additional
48  };
49  };
50 
51  Logger() {}
52  virtual ~Logger() {}
53 
54  /* Logger writers:
55  * This is the One Function you must implement. Everything else is optional or bull.
56  * It must be possible to call this function in presence and in absence of GUI without crashing the application.
57  * It is not necessary to provide any actual output at all times, but it must be 100% safe to call this function at all times.
58  * You may not throw from this function, it must return in finite time, and it must not call logging functions (to prevent infinite recursion).
59  * Other than that, you can do anything you want with the log messages that you receive.
60  */
61  virtual void Append(const wxString& msg, Logger::level lv = info) = 0;
62 
63  virtual void Clear() {}
64  virtual void CopyContentsToClipboard(cb_optional bool selectionOnly = false) {}
65 
66  virtual void UpdateSettings() {}
67  virtual wxWindow* CreateControl(cb_optional wxWindow* parent) { return nullptr; }
68 
69  virtual bool GetWrapMode() const { return false; }
70  virtual bool HasFeature(cb_optional Feature::Enum feature) const { return false; }
71  virtual void AppendAdditionalMenuItems(cb_optional wxMenu &menu) {}
72 };
73 
74 #endif
virtual ~Logger()
Definition: logger.h:52
virtual bool HasFeature(cb_optional Feature::Enum feature) const
Definition: logger.h:70
virtual void Clear()
Definition: logger.h:63
#define _T(string)
The base class for all kinds of loggers, see loggers.h for its derived classes.
Definition: logger.h:23
virtual wxWindow * CreateControl(cb_optional wxWindow *parent)
Definition: logger.h:67
#define DLLIMPORT
Definition: settings.h:16
Logger()
Definition: logger.h:51
level
Definition: logger.h:37
virtual bool GetWrapMode() const
Definition: logger.h:69
virtual void AppendAdditionalMenuItems(cb_optional wxMenu &menu)
Definition: logger.h:71
virtual void UpdateSettings()
Definition: logger.h:66
virtual void CopyContentsToClipboard(cb_optional bool selectionOnly=false)
Definition: logger.h:64