Add ioOp for TraceMsg and cleanup MetalClaw
This commit is contained in:
9
deps/ox/src/ox/trace/trace.cpp
vendored
9
deps/ox/src/ox/trace/trace.cpp
vendored
@@ -6,7 +6,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <ox/std/std.hpp>
|
||||
#include <ox/mc/write.hpp>
|
||||
|
||||
#include "trace.hpp"
|
||||
|
||||
@@ -19,4 +19,11 @@ OutStream::OutStream(const char *file, int line, const char *ch, const char *msg
|
||||
m_msg.msg = msg;
|
||||
}
|
||||
|
||||
OutStream::~OutStream() {
|
||||
constexpr size_t buffLen = 1024;
|
||||
size_t size = 0;
|
||||
uint8_t buff[buffLen];
|
||||
writeMC(buff, buffLen, &m_msg, &size);
|
||||
}
|
||||
|
||||
}
|
||||
|
23
deps/ox/src/ox/trace/trace.hpp
vendored
23
deps/ox/src/ox/trace/trace.hpp
vendored
@@ -13,13 +13,24 @@
|
||||
namespace ox {
|
||||
|
||||
struct TraceMsg {
|
||||
const char *file;
|
||||
int line;
|
||||
uint64_t time;
|
||||
const char *ch;
|
||||
ox::BString<150> file = "";
|
||||
int line = 0;
|
||||
uint64_t time = 0;
|
||||
ox::BString<50> ch = "";
|
||||
ox::BString<100> msg;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
int ioOp(T *io, ox::TraceMsg *obj) {
|
||||
int32_t err = 0;
|
||||
io->setFields(5);
|
||||
err |= io->op("file", &obj->file);
|
||||
err |= io->op("line", &obj->line);
|
||||
err |= io->op("time", &obj->time);
|
||||
err |= io->op("msg", &obj->msg);
|
||||
return err;
|
||||
}
|
||||
|
||||
class OutStream {
|
||||
|
||||
private:
|
||||
@@ -30,6 +41,8 @@ class OutStream {
|
||||
|
||||
OutStream(const char *file, int line, const char *ch, const char *msg = "");
|
||||
|
||||
~OutStream();
|
||||
|
||||
template<typename T>
|
||||
OutStream &operator<<(T v) {
|
||||
m_msg.msg += " ";
|
||||
@@ -41,4 +54,4 @@ class OutStream {
|
||||
|
||||
}
|
||||
|
||||
#define oxTrace(ch, msg) ox::OutStream(__FILE__, __LINE__, ch, msg)
|
||||
#define oxTrace(ch) ox::OutStream(__FILE__, __LINE__, ch)
|
||||
|
Reference in New Issue
Block a user