*** empty log message ***

This commit is contained in:
Magnus Jonsson 2004-01-23 00:39:05 +00:00
parent 60d04d29d7
commit de5fc73d41
2 changed files with 43 additions and 17 deletions

View File

@ -45,37 +45,31 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/preprocessor/repetition/enum.hpp> #include <boost/preprocessor/repetition/enum.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp> #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
namespace libtorrent { namespace libtorrent {
// TODO: all alerts should have a timestamp
class alert class alert
{ {
public: public:
enum severity_t { debug, info, warning, critical, fatal, none }; enum severity_t { debug, info, warning, critical, fatal, none };
alert(severity_t severity, const std::string& msg) alert(severity_t severity, const std::string& msg);
: m_msg(msg) virtual ~alert();
, m_severity(severity)
{}
virtual ~alert() {} // a timestamp is automatically created in the constructor
boost::posix_time::ptime timestamp() const;
const std::string& msg() const const std::string& msg() const;
{
return m_msg;
}
severity_t severity() const severity_t severity() const;
{
return m_severity;
}
virtual std::auto_ptr<alert> clone() const = 0; virtual std::auto_ptr<alert> clone() const = 0;
private: private:
std::string m_msg; std::string m_msg;
severity_t m_severity; severity_t m_severity;
boost::posix_time::ptime m_timestamp;
}; };
class alert_manager class alert_manager
@ -89,8 +83,7 @@ namespace libtorrent {
std::auto_ptr<alert> get(); std::auto_ptr<alert> get();
void set_severity(alert::severity_t severity); void set_severity(alert::severity_t severity);
bool should_post(alert::severity_t severity) const bool should_post(alert::severity_t severity) const;
{ return severity >= m_severity; }
private: private:
std::queue<alert*> m_alerts; std::queue<alert*> m_alerts;

View File

@ -34,6 +34,34 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent { namespace libtorrent {
alert::alert(severity_t severity, const std::string& msg)
: m_msg(msg)
, m_severity(severity)
, m_timestamp(boost::posix_time::second_clock::local_time())
{
}
alert::~alert()
{
}
boost::posix_time::ptime alert::timestamp() const
{
return m_timestamp;
}
const std::string& alert::msg() const
{
return m_msg;
}
alert::severity_t alert::severity() const
{
return m_severity;
}
alert_manager::alert_manager() alert_manager::alert_manager()
: m_severity(alert::none) : m_severity(alert::none)
{} {}
@ -86,6 +114,11 @@ namespace libtorrent {
m_severity = severity; m_severity = severity;
} }
bool alert_manager::should_post(alert::severity_t severity) const
{
return severity >= m_severity;
}
} // namespace libtorrent } // namespace libtorrent