[+] NT OutputDebugStringW logger sink

[*] Split objects
[*] Consider making ABI object api boilerplate
[*] Refactor STLShims (roxtl)
This commit is contained in:
Reece Wilson 2022-03-31 01:31:40 +01:00
parent 5baf182c6f
commit f717511a10
13 changed files with 261 additions and 108 deletions

View File

@ -36,6 +36,11 @@ namespace Aurora::Logging
*/
AUKN_SHARED_API(NewOSNamedEventDirectorySink, IBasicSink, const AuString &name);
/**
* @brief Visual Studio Output
*/
AUKN_SHARED_API(NewDebugLogger, IBasicSink);
/**
* @brief Constructs a text of binary log file sink
*/

View File

@ -188,6 +188,9 @@ namespace Aurora
/// Delegate stdout writes to loops -> recommended for servers
bool asyncWrite {true};
/// Async debug log
bool asyncVSLog {false};
/// Should stdout print the full date or a mere HH MM SS prefix?
bool stdOutShortTime {false};

View File

@ -187,105 +187,4 @@
#define AU_EMIT_FIRST_COMMA_FIRST(n)n
#define AU_EMIT_FIRST_COMMA_OTHERS(n),n
/// @hideinitializer
#define AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(variable) AuRemoveConst_t<AuRemoveReference_t<decltype(variable)>>
/// @hideinitializer
#define AU_EMIT_CTOR_CPY(pair) const AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(pair) &pair
/// @hideinitializer
#define AU_EMIT_CTOR_CPY_SECOND(pair) ,AU_EMIT_CTOR_CPY(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_MOV(pair) AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(pair) &&pair
/// @hideinitializer
#define AU_EMIT_CTOR_MOV_SECOND(pair) ,AU_EMIT_CTOR_MOV(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN(pair) pair(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN_SECOND(pair) ,AU_EMIT_CTOR_ASSIGN(pair)
/// @hideinitializer
#define AU_DEFINE_CTOR_CPY_VA(thisType, args) \
inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_CPY, AU_EMIT_CTOR_CPY_SECOND, AU_STRIP_BRACKETS(args))) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN, AU_EMIT_CTOR_ASSIGN_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN2(pair) pair(cpy.pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN2_SECOND(pair) ,AU_EMIT_CTOR_ASSIGN2(pair)
#define AU_DEFINE_THIS_COPY_CTOR_VA(thisType, args) \
inline thisType(const thisType &cpy) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN2, AU_EMIT_CTOR_ASSIGN2_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_EMIT_CTOR_MOVE_ASSIGN2(pair) pair(AuMove(cpy.pair))
/// @hideinitializer
#define AU_EMIT_CTOR_MOVE_ASSIGN2_SECOND(pair) ,AU_EMIT_CTOR_MOVE_ASSIGN2(pair)
#define AU_DEFINE_THIS_MOVE_CTOR_VA(thisType, args) \
inline thisType(thisType &&cpy) noexcept : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOVE_ASSIGN2, AU_EMIT_CTOR_MOVE_ASSIGN2_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_DEFINE_CTOR_MOV_VA(thisType, args) \
inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOV, AU_EMIT_CTOR_MOV_SECOND, AU_STRIP_BRACKETS(args))) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN, AU_EMIT_CTOR_ASSIGN_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_DEFINE_CTOR_VA_(thisType, args) AU_DEFINE_CTOR_CPY_VA(thisType, args) AU_DEFINE_CTOR_MOV_VA(thisType, args)
/// @deprecated
#define AU_DEFINE_CTOR_ONE(thisType, pairTypeName) AU_DEFINE_CTOR_VA_(thisType, (AU_EMIT_SECOND pairTypeName))
///
#define AU_DEFINE_CTOR_VA(thisType, args) AU_DEFINE_CTOR_CPY_VA(thisType, args) AU_DEFINE_CTOR_MOV_VA(thisType, args)
/// @hideinitializer
#define AU_DEFINE_EQUALS_VA_A(name) this->name == ref.name
/// @hideinitializer
#define AU_DEFINE_EQUALS_VA_B(name) && AU_DEFINE_EQUALS_VA_A(name)
///
#define AU_DEFINE_EQUALS_VA(thisType, args) bool operator==(const thisType & ref) const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_VA_A, AU_DEFINE_EQUALS_VA_B, AU_STRIP_BRACKETS(args)) ; }
/// @hideinitializer
#define AU_DEFINE_EQUALS_HASHCODE_A(name) AuHashCode(this->name)
/// @hideinitializer
#define AU_DEFINE_EQUALS_HASHCODE_B(name) ^ AU_DEFINE_EQUALS_HASHCODE_A(name)
///
#define AU_DEFINE_HASHCODE_VA(thisType, args) AuUInt HashCode() const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_HASHCODE_A, AU_DEFINE_EQUALS_HASHCODE_B, AU_STRIP_BRACKETS(args)) ; }
/// @hideinitializer
#define AU_DEFINE_MOVE_VA_A(name) this->name = AuMove(ref.name);
/// @hideinitializer
#define AU_DEFINE_MOVE_VA_B(name) AU_DEFINE_MOVE_VA_A(name)
///
#define AU_DEFINE_MOVE_VA(thisType, args) thisType& operator=( thisType && ref) noexcept { AU_FOR_EACH_FIRST(AU_DEFINE_MOVE_VA_A, AU_DEFINE_MOVE_VA_B, AU_STRIP_BRACKETS(args)) return *this; }
/// @hideinitializer
#define AU_DEFINE_COPY_VA_A(name) this->name = ref.name;
/// @hideinitializer
#define AU_DEFINE_COPY_VA_B(name) AU_DEFINE_COPY_VA_A(name)
///
#define AU_DEFINE_COPY_VA(thisType, args) thisType& operator=(const thisType & ref) { AU_FOR_EACH_FIRST(AU_DEFINE_COPY_VA_A, AU_DEFINE_COPY_VA_B, AU_STRIP_BRACKETS(args)) return *this; }
#define AU_DEFINE_FOR_VA_(pair, func) func(AU_EMIT_SECOND pair, AU_STRIP_BRACKETS(AU_EMIT_FIRST pair))
#define AU_DEFINE_FOR_VA(type, arry, members) AU_FOR_EACH_THAT(AU_DEFINE_FOR_VA_, ((members), type), AU_STRIP_BRACKETS(arry))
#include "Objects/Objects.hpp"

View File

@ -0,0 +1,131 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Objects.hpp
File: AuroraMacros.hpp
File: AU_MACROS.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
/*
AU_DEFINE_FOR_VA(Object,
(AU_DEFINE_CTOR_VA, // initializer-list-like ctor (extending a struct or adding a ctor will break initializer lists)
AU_DEFINE_THIS_MOVE_CTOR_VA, // add move `Object(Object &&)`
AU_DEFINE_EQUALS_VA, // add equals operator
AU_DEFINE_MOVE_VA, // add move assignment operator
AU_DEFINE_COPY_VA), // add copy assignment operator
(id, task));
*/
/// @hideinitializer
#define AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(variable) AuRemoveConst_t<AuRemoveReference_t<decltype(variable)>>
/// @hideinitializer
#define AU_EMIT_CTOR_CPY(pair) const AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(pair) &pair
/// @hideinitializer
#define AU_EMIT_CTOR_CPY_SECOND(pair) ,AU_EMIT_CTOR_CPY(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_MOV(pair) AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(pair) &&pair
/// @hideinitializer
#define AU_EMIT_CTOR_MOV_SECOND(pair) ,AU_EMIT_CTOR_MOV(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN(pair) pair(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN_SECOND(pair) ,AU_EMIT_CTOR_ASSIGN(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN2(pair) pair(cpy.pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN2_SECOND(pair) ,AU_EMIT_CTOR_ASSIGN2(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_MOVE_ASSIGN2(pair) pair(AuMove(cpy.pair))
/// @hideinitializer
#define AU_EMIT_CTOR_MOVE_ASSIGN2_SECOND(pair) ,AU_EMIT_CTOR_MOVE_ASSIGN2(pair)
/// @hideinitializer
#define AU_DEFINE_CTOR_VA_(thisType, args) AU_DEFINE_CTOR_CPY_VA(thisType, args) AU_DEFINE_CTOR_MOV_VA(thisType, args)
/// @deprecated
#define AU_DEFINE_CTOR_ONE(thisType, pairTypeName) AU_DEFINE_CTOR_VA_(thisType, (AU_EMIT_SECOND pairTypeName))
/// @hideinitializer
#define AU_DEFINE_EQUALS_VA_A(name) this->name == ref.name
/// @hideinitializer
#define AU_DEFINE_EQUALS_VA_B(name) && AU_DEFINE_EQUALS_VA_A(name)
/// @hideinitializer
#define AU_DEFINE_EQUALS_HASHCODE_A(name) AuHashCode(this->name)
/// @hideinitializer
#define AU_DEFINE_EQUALS_HASHCODE_B(name) ^ AU_DEFINE_EQUALS_HASHCODE_A(name)
/// @hideinitializer
#define AU_DEFINE_MOVE_VA_A(name) this->name = AuMove(ref.name);
/// @hideinitializer
#define AU_DEFINE_MOVE_VA_B(name) AU_DEFINE_MOVE_VA_A(name)
/// @hideinitializer
#define AU_DEFINE_COPY_VA_A(name) this->name = ref.name;
/// @hideinitializer
#define AU_DEFINE_COPY_VA_B(name) AU_DEFINE_COPY_VA_A(name)
/// @hideinitializer
#define AU_DEFINE_CTOR_CPY_VA(thisType, args) \
inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_CPY, AU_EMIT_CTOR_CPY_SECOND, AU_STRIP_BRACKETS(args))) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN, AU_EMIT_CTOR_ASSIGN_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_DEFINE_CTOR_MOV_VA(thisType, args) \
inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOV, AU_EMIT_CTOR_MOV_SECOND, AU_STRIP_BRACKETS(args))) noexcept : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN, AU_EMIT_CTOR_ASSIGN_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_DEFINE_THIS_COPY_CTOR_VA(thisType, args) \
inline thisType(const thisType &cpy) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN2, AU_EMIT_CTOR_ASSIGN2_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_DEFINE_THIS_MOVE_CTOR_VA(thisType, args) \
inline thisType(thisType &&cpy) noexcept : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOVE_ASSIGN2, AU_EMIT_CTOR_MOVE_ASSIGN2_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_DEFINE_FOR_VA_(pair, func) func(AU_EMIT_SECOND pair, AU_STRIP_BRACKETS(AU_EMIT_FIRST pair))
///
#define AU_DEFINE_HASHCODE_VA(thisType, args) AuUInt HashCode() const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_HASHCODE_A, AU_DEFINE_EQUALS_HASHCODE_B, AU_STRIP_BRACKETS(args)) ; }
///
#define AU_DEFINE_CTOR_VA(thisType, args) AU_DEFINE_CTOR_CPY_VA(thisType, args) AU_DEFINE_CTOR_MOV_VA(thisType, args)
///
#define AU_DEFINE_EQUALS_VA(thisType, args) bool operator==(const thisType & ref) const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_VA_A, AU_DEFINE_EQUALS_VA_B, AU_STRIP_BRACKETS(args)) ; }
///
#define AU_DEFINE_MOVE_VA(thisType, args) thisType& operator=( thisType && ref) noexcept { AU_FOR_EACH_FIRST(AU_DEFINE_MOVE_VA_A, AU_DEFINE_MOVE_VA_B, AU_STRIP_BRACKETS(args)) return *this; }
///
#define AU_DEFINE_COPY_VA(thisType, args) thisType& operator=(const thisType & ref) { AU_FOR_EACH_FIRST(AU_DEFINE_COPY_VA_A, AU_DEFINE_COPY_VA_B, AU_STRIP_BRACKETS(args)) return *this; }
//
#define AU_DEFINE_FOR_VA(type, arry, members) AU_FOR_EACH_THAT(AU_DEFINE_FOR_VA_, ((members), type), AU_STRIP_BRACKETS(arry))

View File

@ -0,0 +1,8 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ModuleApi.hpp
Date: 2022-3-31
Author: Reece
***/
#pragma once

View File

@ -0,0 +1,11 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Objects.hpp
Date: 2022-3-31
Author: Reece
***/
#pragma once
#include "ClassHelpers.hpp"
#include "ModuleApi.hpp"

View File

@ -34,7 +34,7 @@ using AuWPtr = AURORA_RUNTIME_AU_WEAK_PTR<T>;
template <class T>
using AuDefaultDeleter = AURORA_RUNTIME_AU_DEFAULT_DELETER<T>;
#include "Shims/ExtendStlLikeSharedPtr.hpp"
#include "STLShims/ExtendStlLikeSharedPtr.hpp"
template <class T>
using AuSPtr = typename Aurora::Memory::ExSharedPtr<T, AURORA_RUNTIME_AU_SHARED_PTR<T>>;

View File

@ -66,6 +66,17 @@ namespace Aurora::Console
Hooks::Init();
ConsoleStd::Init();
ConsoleWxWidgets::Init();
#if defined(AURORA_IS_MODERNNT_DERIVED) && (defined(STAGING) || defined(DEBUG))
#if defined(STAGING)
if (IsDebuggerPresent())
{
#endif
AddDefaultLogger(NewDebugLoggerShared());
#if defined(STAGING)
}
#endif
#endif
}
void Init2()

View File

@ -287,11 +287,6 @@ namespace Aurora::Console::ConsoleStd
void WriteStdOut(AuUInt8 level, const ConsoleMessage &msg)
{
#if (defined(DEBUG) || defined(STAGING)) && defined(AURORA_IS_MODERNNT_DERIVED)
auto debugLine = msg.ToSimplified() + "\r\n";
OutputDebugStringW(Locale::ConvertFromUTF8(debugLine).c_str());
#endif
auto writeLine = msg.ToConsole();
#if defined(AURORA_IS_MODERNNT_DERIVED)

View File

@ -17,6 +17,10 @@
#include "Sinks/EventLog.Win32.hpp"
#endif
#if defined(AURORA_IS_MODERNNT_DERIVED)
#include "Sinks/DebugLogger.NT.hpp"
#endif
namespace Aurora::Logging
{
AUKN_SYM IBasicSink *NewStdSinkNew()
@ -35,9 +39,20 @@ namespace Aurora::Logging
}
AUKN_SYM void NewOSEventDirectorySinkRelease(IBasicSink *sink)
{}
AUKN_SYM IBasicSink *NewDebugLoggerNew()
{
return Sinks::NewDebugLoggerNew();
}
AUKN_SYM void NewDebugLoggerRelease(IBasicSink *sink)
{
return Sinks::NewDebugLoggerRelease(sink);
}
AUKN_SYM IBasicSink *NewOSNamedEventDirectorySinkNew(const AuString &name)
{
#if defined(AURORA_PLATFORM_WIN32)

View File

@ -0,0 +1,46 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: DeebugLogger.NT.cpp
Date: 2022-3-31
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "DebugLogger.NT.hpp"
namespace Aurora::Logging::Sinks
{
void ConsoleDebugLogger::OnMessageBlocking(AuUInt8 level, const ConsoleMessage &msg)
{
if (!gRuntimeConfig.console.asyncVSLog) return;
Write(msg);
}
bool ConsoleDebugLogger::OnMessageNonblocking(AuUInt8 level, const ConsoleMessage &msg)
{
if (gRuntimeConfig.console.asyncVSLog) return true;
Write(msg);
return {};
}
void ConsoleDebugLogger::OnFlush()
{}
void ConsoleDebugLogger::Write(const ConsoleMessage &msg)
{
#if (defined(DEBUG) || defined(STAGING)) && defined(AURORA_IS_MODERNNT_DERIVED)
auto debugLine = msg.ToSimplified() + "\r\n";
OutputDebugStringW(Locale::ConvertFromUTF8(debugLine).c_str());
#endif
}
void NewDebugLoggerRelease(IBasicSink *logger)
{
}
IBasicSink *NewDebugLoggerNew()
{
return &gDebugLoggerNt;
}
}

View File

@ -0,0 +1,29 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: DeebugLogger.NT.hpp
Date: 2022-3-31
Author: Reece
***/
#pragma once
namespace Aurora::Logging::Sinks
{
struct ConsoleDebugLogger : IBasicSink
{
void OnMessageBlocking(AuUInt8 level, const ConsoleMessage &msg) override;
bool OnMessageNonblocking(AuUInt8 level, const ConsoleMessage &msg) override;
void OnFlush() override;
private:
//StringBuilder stringBuilder_;
void Write(const ConsoleMessage &msg);
};
inline ConsoleDebugLogger gDebugLoggerNt;
void NewDebugLoggerRelease(IBasicSink *logger);
IBasicSink *NewDebugLoggerNew();
}