[ox/std] Cleanup stdlib/non-stdlib specific build path in logging
This commit is contained in:
parent
3de03bf1fd
commit
95d9aee0cf
20
deps/ox/src/ox/std/def.hpp
vendored
20
deps/ox/src/ox/std/def.hpp
vendored
@ -17,16 +17,9 @@
|
|||||||
#define oxOut(...) ox::trace::OutStream(__FILE__, __LINE__, "stdout", __VA_ARGS__)
|
#define oxOut(...) ox::trace::OutStream(__FILE__, __LINE__, "stdout", __VA_ARGS__)
|
||||||
#define oxErr(...) ox::trace::OutStream(__FILE__, __LINE__, "stderr", __VA_ARGS__)
|
#define oxErr(...) ox::trace::OutStream(__FILE__, __LINE__, "stderr", __VA_ARGS__)
|
||||||
|
|
||||||
#ifdef OX_USE_STDLIB
|
#define oxTracef(ch, fmt, ...) ox::trace::TraceStream(__FILE__, __LINE__, ch, ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), __VA_ARGS__)
|
||||||
// Non-GCC compilers don't like ##__VA_ARGS__, so use initializer list, which relies on std lib
|
#define oxOutf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "stdout", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), __VA_ARGS__)
|
||||||
#define oxTracef(ch, fmt, ...) ox::trace::TraceStream(__FILE__, __LINE__, ch, ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), {__VA_ARGS__})
|
#define oxErrf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "stderr", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), __VA_ARGS__)
|
||||||
#define oxOutf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "stdout", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), {__VA_ARGS__})
|
|
||||||
#define oxErrf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "stderr", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), {__VA_ARGS__})
|
|
||||||
#else
|
|
||||||
#define oxTracef(ch, fmt, ...) ox::trace::TraceStream(__FILE__, __LINE__, ch, ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), ##__VA_ARGS__)
|
|
||||||
#define oxOutf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "stdout", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), ##__VA_ARGS__)
|
|
||||||
#define oxErrf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "stderr", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), ##__VA_ARGS__)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define oxInfo(...) oxTrace("info", __VA_ARGS__)
|
#define oxInfo(...) oxTrace("info", __VA_ARGS__)
|
||||||
#define oxInfof(...) oxTracef("info", __VA_ARGS__)
|
#define oxInfof(...) oxTracef("info", __VA_ARGS__)
|
||||||
@ -35,12 +28,7 @@
|
|||||||
|
|
||||||
#ifndef OX_NODEBUG
|
#ifndef OX_NODEBUG
|
||||||
#define oxDebug(...) ox::trace::OutStream(__FILE__, __LINE__, "debug", __VA_ARGS__)
|
#define oxDebug(...) ox::trace::OutStream(__FILE__, __LINE__, "debug", __VA_ARGS__)
|
||||||
#ifdef OX_USE_STDLIB
|
#define oxDebugf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "debug", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), __VA_ARGS__)
|
||||||
// Non-GCC compilers don't like ##__VA_ARGS__, so use initializer list, which relies on std lib
|
|
||||||
#define oxDebugf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "debug", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), {__VA_ARGS__})
|
|
||||||
#else
|
|
||||||
#define oxDebugf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "debug", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), ##__VA_ARGS__)
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#define oxDebug(...) static_assert(false, "Debug prints were checked in.");
|
#define oxDebug(...) static_assert(false, "Debug prints were checked in.");
|
||||||
#define oxDebugf(...) static_assert(false, "Debug prints were checked in.");
|
#define oxDebugf(...) static_assert(false, "Debug prints were checked in.");
|
||||||
|
36
deps/ox/src/ox/std/trace.hpp
vendored
36
deps/ox/src/ox/std/trace.hpp
vendored
@ -141,39 +141,22 @@ class OutStream {
|
|||||||
m_msg.msg = msg;
|
m_msg.msg = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OX_USE_STDLIB
|
|
||||||
template<std::size_t fmtSegmentCnt, typename ...Args>
|
template<std::size_t fmtSegmentCnt, typename ...Args>
|
||||||
constexpr OutStream(const char *file, int line, const char *ch, detail::Fmt<fmtSegmentCnt> fmtSegments, std::array<detail::FmtArg, fmtSegmentCnt - 1> elements) noexcept {
|
constexpr OutStream(const char *file, int line, const char *ch, detail::Fmt<fmtSegmentCnt> fmtSegments, Args const&...elements) noexcept {
|
||||||
//static_assert(sizeof...(args) == fmtSegmentCnt - 1, "Wrong number of trace arguments for format.");
|
static_assert(sizeof...(elements) == fmtSegmentCnt - 1, "Wrong number of trace arguments for format.");
|
||||||
m_msg.file = file;
|
m_msg.file = file;
|
||||||
m_msg.line = line;
|
m_msg.line = line;
|
||||||
m_msg.ch = ch;
|
m_msg.ch = ch;
|
||||||
const auto &firstSegment = fmtSegments.segments[0];
|
const auto &firstSegment = fmtSegments.segments[0];
|
||||||
oxIgnoreError(m_msg.msg.append(firstSegment.str, firstSegment.length));
|
oxIgnoreError(m_msg.msg.append(firstSegment.str, firstSegment.length));
|
||||||
//const detail::FmtArg elements[sizeof...(args)] = {args...};
|
//const detail::FmtArg elements[sizeof...(args)] = {args...};
|
||||||
for (size_t i = 0; i < fmtSegments.size - 1; ++i) {
|
for (size_t i = 0; auto const&e : std::initializer_list<detail::FmtArg>{elements...}) {
|
||||||
m_msg.msg += elements[i].out;
|
m_msg.msg += e.out;
|
||||||
const auto &s = fmtSegments.segments[i + 1];
|
const auto &s = fmtSegments.segments[i + 1];
|
||||||
oxIgnoreError(m_msg.msg.append(s.str, s.length));
|
oxIgnoreError(m_msg.msg.append(s.str, s.length));
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
template<std::size_t fmtSegmentCnt, typename ...Args>
|
|
||||||
constexpr OutStream(const char *file, int line, const char *ch, detail::Fmt<fmtSegmentCnt> fmtSegments, Args const&...args) noexcept {
|
|
||||||
//static_assert(sizeof...(args) == fmtSegmentCnt - 1, "Wrong number of trace arguments for format.");
|
|
||||||
m_msg.file = file;
|
|
||||||
m_msg.line = line;
|
|
||||||
m_msg.ch = ch;
|
|
||||||
const auto &firstSegment = fmtSegments.segments[0];
|
|
||||||
oxIgnoreError(m_msg.msg.append(firstSegment.str, firstSegment.length));
|
|
||||||
const detail::FmtArg elements[sizeof...(args)] = {args...};
|
|
||||||
for (auto i = 0u; i < fmtSegments.size - 1; ++i) {
|
|
||||||
m_msg.msg += elements[i].out;
|
|
||||||
const auto &s = fmtSegments.segments[i + 1];
|
|
||||||
oxIgnoreError(m_msg.msg.append(s.str, s.length));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline ~OutStream() noexcept {
|
inline ~OutStream() noexcept {
|
||||||
oxTraceHook(m_msg.file, m_msg.line, m_msg.ch, m_msg.msg.c_str());
|
oxTraceHook(m_msg.file, m_msg.line, m_msg.ch, m_msg.msg.c_str());
|
||||||
@ -257,15 +240,10 @@ class NullStream {
|
|||||||
constexpr NullStream(const char*, int, const char*, const char* = "") noexcept {
|
constexpr NullStream(const char*, int, const char*, const char* = "") noexcept {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OX_USE_STDLIB
|
|
||||||
template<std::size_t fmtSegmentCnt, typename ...Args>
|
template<std::size_t fmtSegmentCnt, typename ...Args>
|
||||||
constexpr NullStream(const char*, int, const char*, detail::Fmt<fmtSegmentCnt>, std::array<detail::FmtArg, fmtSegmentCnt - 1>) noexcept {
|
constexpr NullStream(const char*, int, const char*, detail::Fmt<fmtSegmentCnt>, Args const&...elements) noexcept {
|
||||||
|
static_assert(sizeof...(elements) == fmtSegmentCnt - 1, "Wrong number of trace arguments for format.");
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
template<std::size_t fmtSegmentCnt, typename ...Args>
|
|
||||||
constexpr NullStream(const char*, int, const char*, detail::Fmt<fmtSegmentCnt>, Args...) noexcept {
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr const NullStream &operator<<(const T&) const noexcept {
|
constexpr const NullStream &operator<<(const T&) const noexcept {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user