summaryrefslogtreecommitdiff
path: root/src/printutils.h
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2012-10-28 13:56:23 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2012-10-28 13:56:23 (GMT)
commit4ecd9fa8a4ceeb49ec62a50197f4fa4da9276796 (patch)
treec298e527789aeecb2c742044683471a48c9acf1a /src/printutils.h
parent1dbcd7f4689fd0ed84997e2fb80a1b77e06f6b26 (diff)
refactor, cleanup, put code where it belongs, make simple logging class
Diffstat (limited to 'src/printutils.h')
-rw-r--r--src/printutils.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/printutils.h b/src/printutils.h
index 521682c..935463e 100644
--- a/src/printutils.h
+++ b/src/printutils.h
@@ -3,7 +3,9 @@
#include <string>
#include <list>
+#include <map>
#include <iostream>
+#include <sstream>
#include <boost/format.hpp>
typedef void (OutputHandlerFunc)(const std::string &msg, void *userdata);
@@ -22,4 +24,26 @@ void PRINT(const std::string &msg);
void PRINT_NOCACHE(const std::string &msg);
#define PRINTB_NOCACHE(_fmt, _arg) do { PRINT_NOCACHE(str(boost::format(_fmt) % _arg)); } while (0)
+// extremely simple logging, eventually replace with something like boost.log
+// usage: logstream out(5); openscad_loglevel=6; out << "hi";
+static int openscad_loglevel = 0;
+class logstream
+{
+public:
+ std::ostream *out;
+ int loglevel;
+ logstream( int level = 0 ) {
+ loglevel = level;
+ out = &(std::cout);
+ }
+ template <typename T> logstream & operator<<( T const &t ) {
+ if (out && loglevel <= openscad_loglevel) {
+ (*out) << t ;
+ out->flush();
+ }
+ return *this;
+ }
+};
+
+
#endif
contact: Jan Huwald // Impressum