aboutsummaryrefslogtreecommitdiff
path: root/src/libmatrix/log.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmatrix/log.h')
-rw-r--r--src/libmatrix/log.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/libmatrix/log.h b/src/libmatrix/log.h
new file mode 100644
index 0000000..9054323
--- /dev/null
+++ b/src/libmatrix/log.h
@@ -0,0 +1,51 @@
+//
+// Copyright (c) 2010-2012 Linaro Limited
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the MIT License which accompanies
+// this distribution, and is available at
+// http://www.opensource.org/licenses/mit-license.php
+//
+// Contributors:
+// Alexandros Frantzis <alexandros.frantzis@linaro.org>
+// Jesse Barker <jesse.barker@linaro.org>
+//
+#ifndef LOG_H_
+#define LOG_H_
+
+#include <string>
+#include <iostream>
+
+class Log
+{
+public:
+ static void init(const std::string& appname, bool do_debug = false,
+ std::ostream *extra_out = 0)
+ {
+ appname_ = appname;
+ do_debug_ = do_debug;
+ extra_out_ = extra_out;
+ }
+ // Emit an informational message
+ static void info(const char *fmt, ...);
+ // Emit a debugging message
+ static void debug(const char *fmt, ...);
+ // Emit an error message
+ static void error(const char *fmt, ...);
+ // Explicit flush of the log buffer
+ static void flush();
+ // A prefix constant that informs the logging infrastructure that the log
+ // message is a continuation of a previous log message to be put on the
+ // same line.
+ static const std::string continuation_prefix;
+private:
+ // A constant for identifying the log messages as originating from a
+ // particular application.
+ static std::string appname_;
+ // Indicates whether debug level messages should generate any output
+ static bool do_debug_;
+ // Extra stream to output log messages to
+ static std::ostream *extra_out_;
+};
+
+#endif /* LOG_H_ */