Start fleshing out tracing library
This commit is contained in:
17
deps/ox/src/ox/trace/trace.cpp
vendored
17
deps/ox/src/ox/trace/trace.cpp
vendored
@@ -6,24 +6,17 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ox/std/std.hpp>
|
||||
|
||||
#include "trace.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
||||
struct TraceMsg {
|
||||
const char *file;
|
||||
int line;
|
||||
uint64_t time;
|
||||
const char *ch;
|
||||
const char *msg;
|
||||
};
|
||||
|
||||
void trace(const char *file, int line, const char *ch, const char *msg) {
|
||||
OutStream::OutStream(const char *file, int line, const char *ch, const char *msg) {
|
||||
m_msg.file = file;
|
||||
m_msg.line = line;
|
||||
m_msg.ch = ch;
|
||||
m_msg.msg = msg;
|
||||
}
|
||||
|
||||
}
|
||||
|
31
deps/ox/src/ox/trace/trace.hpp
vendored
31
deps/ox/src/ox/trace/trace.hpp
vendored
@@ -8,10 +8,37 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/std.hpp>
|
||||
|
||||
namespace ox {
|
||||
|
||||
void trace(const char *file, int line, const char *ch, const char *msg);
|
||||
struct TraceMsg {
|
||||
const char *file;
|
||||
int line;
|
||||
uint64_t time;
|
||||
const char *ch;
|
||||
ox::BString<100> msg;
|
||||
};
|
||||
|
||||
class OutStream {
|
||||
|
||||
private:
|
||||
TraceMsg m_msg;
|
||||
|
||||
public:
|
||||
OutStream() = default;
|
||||
|
||||
OutStream(const char *file, int line, const char *ch, const char *msg = "");
|
||||
|
||||
template<typename T>
|
||||
OutStream &operator<<(T v) {
|
||||
m_msg.msg += " ";
|
||||
m_msg.msg += v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#define ox_trace(ch, msg) ox::trace(__FILE__, __LINE__, ch, msg)
|
||||
#define oxTrace(ch, msg) ox::OutStream(__FILE__, __LINE__, ch, msg)
|
||||
|
Reference in New Issue
Block a user