summaryrefslogtreecommitdiff
path: root/src/utils/logger.h
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-02-28 19:06:40 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-02-28 19:06:40 +0100
commitb89e404f85358f2e3ff87d7731376dbeacdf9778 (patch)
treee391237c46bb6fb3cfe184f65a306af54138dddb /src/utils/logger.h
parent7a75bd8b0215a3d8ad1e6be7baf5e6a056d1607a (diff)
parent626e4c98353f2111ae21123756396fc845447b57 (diff)
downloadmanaserv-b89e404f85358f2e3ff87d7731376dbeacdf9778.tar.gz
manaserv-b89e404f85358f2e3ff87d7731376dbeacdf9778.tar.bz2
manaserv-b89e404f85358f2e3ff87d7731376dbeacdf9778.tar.xz
manaserv-b89e404f85358f2e3ff87d7731376dbeacdf9778.zip
Merge branch 'master' into lpc2012
Diffstat (limited to 'src/utils/logger.h')
-rw-r--r--src/utils/logger.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/utils/logger.h b/src/utils/logger.h
index 65846be5..c9ca9d80 100644
--- a/src/utils/logger.h
+++ b/src/utils/logger.h
@@ -24,6 +24,7 @@
#include <iosfwd>
#include <sstream>
+#include <iostream>
namespace utils
{
@@ -192,6 +193,32 @@ class Logger
static void switchLogs();
};
+/**
+ * Class for temporarily debugging things that are actually not interesting
+ * to include in the log.
+ *
+ * It is used for automatically ending with a newline, putting spaces in
+ * between different parameters and quoting strings.
+ */
+class Debug
+{
+public:
+ ~Debug() { std::cout << std::endl; }
+
+ template <class T>
+ Debug &operator << (T t)
+ {
+ std::cout << t << " ";
+ return *this;
+ }
+};
+
+template <>
+inline Debug &Debug::operator << (const std::string &t)
+{
+ std::cout << "\"" << t << "\" ";
+ return *this;
+}
} // namespace utils
@@ -210,4 +237,11 @@ class Logger
#define LOG_ERROR(msg) LOG(Error, msg)
#define LOG_FATAL(msg) LOG(Fatal, msg)
+/**
+ * Returns an instance of the debug class for printing out a line.
+ *
+ * Usage: debug() << "testing" << a << b;
+ */
+inline ::utils::Debug debug() { return ::utils::Debug(); }
+
#endif // LOGGER_H