summaryrefslogtreecommitdiff
path: root/src/printutils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/printutils.h')
-rw-r--r--src/printutils.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/printutils.h b/src/printutils.h
index 521682c..9d99a19 100644
--- a/src/printutils.h
+++ b/src/printutils.h
@@ -22,4 +22,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