aboutsummaryrefslogtreecommitdiff
path: root/frontend/print.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-28 15:41:35 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-28 15:41:35 +0100
commit3562802cacc8dbd0c155146acfdb8d04c6440009 (patch)
treef2139c64c6713d1c59df4b8601c11fca52fa62f5 /frontend/print.h
parenta070c649ddbe70a22f6265b9f5b48f6bde7eac08 (diff)
implement transcript-style log
Diffstat (limited to 'frontend/print.h')
-rw-r--r--frontend/print.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/frontend/print.h b/frontend/print.h
new file mode 100644
index 0000000..6b526ae
--- /dev/null
+++ b/frontend/print.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <cstring>
+#include <memory>
+#include <functional>
+#include <string>
+
+void lprtf(const char * fmt, ...);
+
+class SessionLog {
+public:
+ static SessionLog & get();
+
+private:
+ SessionLog();
+ virtual ~SessionLog() = default;
+
+public:
+ virtual void append(const std::string & str);
+ virtual void append(const char * str);
+ virtual void append(const char * buf, size_t buf_size);
+
+private:
+ std::unique_ptr<FILE, std::function<void(FILE*)>> file = nullptr;
+ static constexpr bool enable = true;
+};
+