gloox  1.0.27
logsink.h
1 /*
2  Copyright (c) 2005-2023 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef LOGSINK_H__
15 #define LOGSINK_H__
16 
17 #include "gloox.h"
18 #include "loghandler.h"
19 
20 #include <string>
21 // #include <fstream>
22 
23 namespace gloox
24 {
25 
38  class GLOOX_API LogSink
39  {
40  public:
44  LogSink();
45 
49  virtual ~LogSink();
50 
58  void log( LogLevel level, LogArea area, const std::string& message ) const;
59 
66  void dbg( LogArea area, const std::string& message ) const
67  { log( LogLevelDebug, area, message ); }
68 
75  void warn( LogArea area, const std::string& message ) const
76  { log( LogLevelWarning, area, message ); }
77 
84  void err( LogArea area, const std::string& message ) const
85  { log( LogLevelError, area, message ); }
86 
94  void registerLogHandler( LogLevel level, int areas, LogHandler* lh );
95 
100  void removeLogHandler( LogHandler* lh );
101 
102  private:
103  struct LogInfo
104  {
105  LogLevel level;
106  int areas;
107  };
108 
109  LogSink( const LogSink& /*copy*/ );
110 
111  typedef std::map<LogHandler*, LogInfo> LogHandlerMap;
112  LogHandlerMap m_logHandlers;
113 
114  };
115 
116 }
117 
118 #endif // LOGSINK_H__
A virtual interface which can be reimplemented to receive debug and log messages.
Definition: loghandler.h:34
An implementation of log sink and source.
Definition: logsink.h:39
void warn(LogArea area, const std::string &message) const
Definition: logsink.h:75
void dbg(LogArea area, const std::string &message) const
Definition: logsink.h:66
void err(LogArea area, const std::string &message) const
Definition: logsink.h:84
The namespace for the gloox library.
Definition: adhoc.cpp:28
LogArea
Definition: gloox.h:1053
LogLevel
Definition: gloox.h:1080
@ LogLevelWarning
Definition: gloox.h:1082
@ LogLevelError
Definition: gloox.h:1083
@ LogLevelDebug
Definition: gloox.h:1081