logsink.h
/*
Copyright (c) 2005-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef LOGSINK_H__
#define LOGSINK_H__
#include "gloox.h"
#include "loghandler.h"
#include <string>
// #include <fstream>
namespace gloox
{
class GLOOX_API LogSink
{
public:
LogSink();
virtual ~LogSink();
void log( LogLevel level, LogArea area, const std::string& message ) const;
void dbg( LogArea area, const std::string& message ) const
{ log( LogLevelDebug, area, message ); }
void warn( LogArea area, const std::string& message ) const
{ log( LogLevelWarning, area, message ); }
void err( LogArea area, const std::string& message ) const
{ log( LogLevelError, area, message ); }
void registerLogHandler( LogLevel level, int areas, LogHandler* lh );
void removeLogHandler( LogHandler* lh );
private:
struct LogInfo
{
LogLevel level;
int areas;
};
LogSink( const LogSink& /*copy*/ );
typedef std::map<LogHandler*, LogInfo> LogHandlerMap;
LogHandlerMap m_logHandlers;
};
}
#endif // LOGSINK_H__
gloox::LogHandler
A virtual interface which can be reimplemented to receive debug and log messages.
Definition loghandler.h:34
gloox::LogSink::LogSink
LogSink()
Definition logsink.cpp:20
gloox::LogSink::warn
void warn(LogArea area, const std::string &message) const
Definition logsink.h:75
gloox::LogSink::log
void log(LogLevel level, LogArea area, const std::string &message) const
Definition logsink.cpp:28
gloox::LogSink::dbg
void dbg(LogArea area, const std::string &message) const
Definition logsink.h:66
gloox::LogSink::err
void err(LogArea area, const std::string &message) const
Definition logsink.h:84
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::LogArea
LogArea
Definition gloox.h:1053
gloox::LogLevel
LogLevel
Definition gloox.h:1080
gloox::LogLevelWarning
@ LogLevelWarning
Definition gloox.h:1082
gloox::LogLevelError
@ LogLevelError
Definition gloox.h:1083
gloox::LogLevelDebug
@ LogLevelDebug
Definition gloox.h:1081