From aa4b3e256377030d291fc2d5f4db94985ce04395 Mon Sep 17 00:00:00 2001 From: DukePyrolator Date: Sun, 31 Jan 2010 06:15:29 +0000 Subject: replaced the alog() command with a new type-safe and stream-based Alog() git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2777 5417fbe8-f217-4b02-8779-1006273d7864 --- include/extern.h | 1 - include/modules.h | 4 ++-- include/services.h | 26 ++++++++++++++++++++++++++ include/users.h | 3 +++ 4 files changed, 31 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/extern.h b/include/extern.h index 2e610f1fa..21b7bdb81 100644 --- a/include/extern.h +++ b/include/extern.h @@ -210,7 +210,6 @@ E const char *getstring(int index); E int open_log(); E void close_log(); -E void alog(const char *fmt, ...) FORMAT(printf,1,2); E void log_perror(const char *fmt, ...) FORMAT(printf,1,2); E void fatal(const char *fmt, ...) FORMAT(printf,1,2); E void fatal_perror(const char *fmt, ...) FORMAT(printf,1,2); diff --git a/include/modules.h b/include/modules.h index 450c48b10..cc42f4abc 100644 --- a/include/modules.h +++ b/include/modules.h @@ -70,7 +70,7 @@ enum EventReturn } \ catch (CoreException& modexcept) \ { \ - alog("Exception caught: %s",modexcept.GetReason()); \ + Alog() << "Exception caught: " << modexcept.GetReason(); \ } \ _i = safei; \ } \ @@ -99,7 +99,7 @@ do { \ } \ catch (CoreException& modexcept) \ { \ - alog("Exception caught: %s",modexcept.GetReason()); \ + Alog() << "Exception caught: " << modexcept.GetReason(); \ } \ _i = safei; \ } \ diff --git a/include/services.h b/include/services.h index eb9fdc34d..7325685f5 100644 --- a/include/services.h +++ b/include/services.h @@ -1162,6 +1162,32 @@ struct Uplink { } }; +enum LogLevel +{ + LOG_NORMAL, + LOG_DEBUG, + LOG_DEBUG_2, + LOG_DEBUG_3, + LOG_DEBUG_4 +}; + +class CoreExport Alog +{ + private: + std::stringstream buf; + bool logit; + public: + Alog(LogLevel val = LOG_NORMAL); + ~Alog(); + template Alog& operator<<(T val) + { + if (logit) + buf << val; + return *this; + } +}; + + class CoreExport Anope { public: diff --git a/include/users.h b/include/users.h index c5b67ab4c..dba200770 100644 --- a/include/users.h +++ b/include/users.h @@ -128,6 +128,9 @@ class CoreExport User : public Extensible */ const std::string &GetIdent() const; + /** Get the full mask ( nick!ident@realhost ) of a user + */ + const std::string GetMask(); /** Updates the realname of the user record. */ void SetRealname(const std::string &realname); -- cgit