libUTL++
LogMgr.h
1 #pragma once
2 
4 
5 #include <libutl/Array.h>
6 #include <libutl/IOmux.h>
7 #include <libutl/Mutex.h>
8 
10 
11 UTL_NS_BEGIN;
12 
14 
15 class LogSetting;
16 class LogStream;
17 
19 
38 
40 class LogMgr : public Object, protected FlagsMI
41 {
43 
44 public:
46  virtual void clear();
47 
49  bool
50  isOwner() const
51  {
52  return getFlag(flg_owner);
53  }
54 
56  void
57  setOwner(bool owner)
58  {
59  setFlag(flg_owner, owner);
60  }
61 
70  void addStream(Stream* stream, uint_t category, uint_t level);
71 
79  void put(const String& str, uint_t category = 0, uint_t level = uint_t_max);
80 
87  void
88  putLine(const String& str, uint_t category = 0, uint_t level = uint_t_max)
89  {
90  put(str + '\n', category, level);
91  }
92 
98  void setLevel(uint_t category, uint_t level);
99 
100 public:
101  static void utl_deInit();
102 
103 private:
104  enum flg_t
105  {
106  flg_owner
107  };
108 
109 private:
110  void init();
111  void deInit();
112 
113 private:
114  Vector<uint_t> _levels;
115  TArray<LogStream>* _logStreams;
116  Mutex* _mutex;
117 };
118 
120 
122 extern LogMgr logMgr;
123 
125 
126 UTL_NS_END;
void putLine(const String &str, uint_t category=0, uint_t level=uint_t_max)
A front-end for put() which logs a newline after the given string.
Definition: LogMgr.h:88
void deInit()
De-initialize UTL++.
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
Character string.
Definition: String.h:31
Mix-in to provide 64-bits for space-efficient storage of up to 64 boolean flags.
Definition: FlagsMI.h:25
MUTual EXclusion device.
Definition: Mutex.h:27
LogMgr logMgr
Global instance of LogMgr.
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
Manage application event logging.
Definition: LogMgr.h:40
const uint_t uint_t_max
Maximum uint_t value.
Stream I/O abstraction.
Definition: Stream.h:68
bool isOwner() const
Get the owner flag.
Definition: LogMgr.h:50
Root of UTL++ class hierarchy.
Definition: Object.h:52
void setOwner(bool owner)
Set the owner flag.
Definition: LogMgr.h:57
void init()
Initialize UTL++.