Start fleshing out tracing library

This commit is contained in:
2018-02-13 19:13:31 -06:00
parent 7856d4e0bf
commit d5b0bb69df
9 changed files with 173 additions and 14 deletions

View File

@@ -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;
}
}

View File

@@ -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)