summaryrefslogtreecommitdiffstats
path: root/xmrstak/misc/console.hpp
diff options
context:
space:
mode:
authorpsychocrypt <psychocrypt@users.noreply.github.com>2017-09-29 20:32:31 +0200
committerpsychocrypt <psychocrypt@users.noreply.github.com>2017-09-30 23:46:08 +0200
commitcc429b68fadc502b981fd0acd64a5ff6e2ae1d15 (patch)
tree3fb23fc4db15dbdd08af4c7ea20134b9d82e58fd /xmrstak/misc/console.hpp
parente5b0319d5a9f58762fa934ad700113908940cb31 (diff)
downloadxmr-stak-cc429b68fadc502b981fd0acd64a5ff6e2ae1d15.zip
xmr-stak-cc429b68fadc502b981fd0acd64a5ff6e2ae1d15.tar.gz
group files
- move source code to `src` - categorize files and move to group folder - change upper case class files to lower case - change C++ header to `*.hpp`
Diffstat (limited to 'xmrstak/misc/console.hpp')
-rw-r--r--xmrstak/misc/console.hpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/xmrstak/misc/console.hpp b/xmrstak/misc/console.hpp
new file mode 100644
index 0000000..ac2ed3c
--- /dev/null
+++ b/xmrstak/misc/console.hpp
@@ -0,0 +1,47 @@
+#pragma once
+#include <mutex>
+#include "Environment.hpp"
+
+enum out_colours { K_RED, K_GREEN, K_BLUE, K_YELLOW, K_CYAN, K_MAGENTA, K_WHITE, K_NONE };
+
+// Warning - on Linux get_key will detect control keys, but not on Windows.
+// We will only use it for alphanum keys anyway.
+int get_key();
+
+void set_colour(out_colours cl);
+void reset_colour();
+
+// on MSVC sizeof(long int) = 4, gcc sizeof(long int) = 8, this is the workaround
+// now we can use %llu on both compilers
+inline long long unsigned int int_port(size_t i)
+{
+ return i;
+}
+
+enum verbosity : size_t { L0 = 0, L1 = 1, L2 = 2, L3 = 3, L4 = 4, LINF = 100};
+
+class printer
+{
+public:
+ static inline printer* inst()
+ {
+ auto& env = xmrstak::Environment::inst();
+ if(env.pPrinter == nullptr)
+ env.pPrinter = new printer;
+ return env.pPrinter;
+ };
+
+ inline void set_verbose_level(size_t level) { verbose_level = (verbosity)level; }
+ void print_msg(verbosity verbose, const char* fmt, ...);
+ void print_str(const char* str);
+ bool open_logfile(const char* file);
+
+private:
+ printer();
+
+ std::mutex print_mutex;
+ verbosity verbose_level;
+ FILE* logfile;
+};
+
+void win_exit();
OpenPOWER on IntegriCloud