gloox  1.0.9
logsink.h
1 /*
2  Copyright (c) 2005-2013 by Jakob Schroeter <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__