Added a common dll for common functions include but not limited to logging and toml configurations.
Some checks failed
MSBuild / build (push) Has been cancelled
Generate DLL Progress JSONs / generate_commit (push) Has been cancelled
Deploy static content to Pages / deploy (push) Has been cancelled

This commit is contained in:
Tyler Jaacks 2024-11-20 00:12:49 -06:00
parent 993f3e0cb9
commit 4fd1aa6b83
11 changed files with 18404 additions and 5 deletions

View File

@ -36,6 +36,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "dlls\common\common.vcxproj", "{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
@ -440,6 +442,38 @@ Global
{6FD783E4-EA7E-40E6-8782-7C0E90CE6D7A}.ReleaseMD|x64.Build.0 = Release|x64
{6FD783E4-EA7E-40E6-8782-7C0E90CE6D7A}.ReleaseMD|x86.ActiveCfg = Release|Win32
{6FD783E4-EA7E-40E6-8782-7C0E90CE6D7A}.ReleaseMD|x86.Build.0 = Release|Win32
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Debug|ARM.ActiveCfg = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Debug|ARM.Build.0 = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Debug|ARM64.ActiveCfg = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Debug|ARM64.Build.0 = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Debug|x64.ActiveCfg = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Debug|x64.Build.0 = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Debug|x86.ActiveCfg = Debug|Win32
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Debug|x86.Build.0 = Debug|Win32
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.DebugMDd|ARM.ActiveCfg = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.DebugMDd|ARM.Build.0 = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.DebugMDd|ARM64.ActiveCfg = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.DebugMDd|ARM64.Build.0 = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.DebugMDd|x64.ActiveCfg = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.DebugMDd|x64.Build.0 = Debug|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.DebugMDd|x86.ActiveCfg = Debug|Win32
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.DebugMDd|x86.Build.0 = Debug|Win32
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Release|ARM.ActiveCfg = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Release|ARM.Build.0 = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Release|ARM64.ActiveCfg = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Release|ARM64.Build.0 = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Release|x64.ActiveCfg = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Release|x64.Build.0 = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Release|x86.ActiveCfg = Release|Win32
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.Release|x86.Build.0 = Release|Win32
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.ReleaseMD|ARM.ActiveCfg = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.ReleaseMD|ARM.Build.0 = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.ReleaseMD|ARM64.ActiveCfg = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.ReleaseMD|ARM64.Build.0 = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.ReleaseMD|x64.ActiveCfg = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.ReleaseMD|x64.Build.0 = Release|x64
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.ReleaseMD|x86.ActiveCfg = Release|Win32
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096}.ReleaseMD|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -457,6 +491,7 @@ Global
{A89A1631-2013-4642-B8A1-7AFE05D5A46B} = {BF759166-26A8-4B46-8423-8091158F2EA5}
{93628D69-C7A5-43E0-A6E7-AE920C666EB4} = {BF759166-26A8-4B46-8423-8091158F2EA5}
{6FD783E4-EA7E-40E6-8782-7C0E90CE6D7A} = {BF759166-26A8-4B46-8423-8091158F2EA5}
{DA57F1D7-7922-44CB-9251-4D0F7E5E4096} = {BF759166-26A8-4B46-8423-8091158F2EA5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {30EA489C-CFA4-4816-BE12-8BCE129039C5}

102
dlls/common/.editorconfig Normal file
View File

@ -0,0 +1,102 @@
# Visual Studio generated .editorconfig file with C++ settings.
root = true
[*.{c++,cc,cl,cpp,cppm,cu,cuh,cxx,fx,fxh,glsl,h,h++,hh,hlsl,hpp,hxx,inl,ipp,ixx,shdbg,tlh,tli}]
# Visual C++ Code Style settings
cpp_generate_documentation_comments = xml
# Visual C++ Formatting settings
cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = true
cpp_indent_case_contents = true
cpp_indent_case_labels = false
cpp_indent_case_contents_when_block = false
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_goto_labels = one_left
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = true
cpp_indent_preserve_comments = false
cpp_new_line_before_open_brace_namespace = ignore
cpp_new_line_before_open_brace_type = ignore
cpp_new_line_before_open_brace_function = ignore
cpp_new_line_before_open_brace_block = ignore
cpp_new_line_before_open_brace_lambda = ignore
cpp_new_line_scope_braces_on_separate_lines = false
cpp_new_line_close_brace_same_line_empty_type = false
cpp_new_line_close_brace_same_line_empty_function = false
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
cpp_new_line_before_while_in_do_while = false
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = false
cpp_space_between_empty_parameter_list_parentheses = true
cpp_space_after_keywords_in_control_flow_statements = true
cpp_space_within_control_flow_statement_parentheses = false
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = false
cpp_space_after_cast_close_parenthesis = true
cpp_space_within_expression_parentheses = false
cpp_space_before_block_open_brace = true
cpp_space_between_empty_braces = false
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = true
cpp_space_preserve_in_initializer_list = true
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = true
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = true
cpp_space_before_constructor_colon = true
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = true
cpp_space_remove_around_unary_operator = true
cpp_space_around_binary_operator = insert
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = left
cpp_space_around_ternary_operator = insert
cpp_use_unreal_engine_macro_formatting = true
cpp_wrap_preserve_blocks = one_liners
# Visual C++ Inlcude Cleanup settings
cpp_include_cleanup_add_missing_error_tag_type = suggestion
cpp_include_cleanup_remove_unused_error_tag_type = dimmed
cpp_include_cleanup_optimize_unused_error_tag_type = suggestion
cpp_include_cleanup_sort_after_edits = false
cpp_sort_includes_error_tag_type = none
cpp_sort_includes_priority_case_sensitive = false
cpp_sort_includes_priority_style = quoted
cpp_includes_style = default
cpp_includes_use_forward_slash = true
# ReSharper C++ settings
resharper_cpp_inconsistent_naming_highlighting = none
resharper_cpp_function_result_should_be_used_highlighting = none
resharper_cpp_parameter_may_be_const_highlighting = none
resharper_cpp_class_can_be_final_highlighting = none
resharper_cpp_polymorphic_class_with_non_virtual_public_destructor_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_non_virtual_dtor_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_header_hygiene_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_inconsistent_dllimport_highlighting = none
resharper_cpp_default_case_not_handled_in_switch_statement_highlighting = none
resharper_cpp_clang_tidy_hicpp_multiway_paths_covered_highlighting = none
resharper_cpp_zero_constant_can_be_replaced_with_nullptr_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_cast_qual_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_cast_align_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_microsoft_cast_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_undefined_reinterpret_cast_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_shadow_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_cast_function_type_strict_highlighting = none
resharper_cpp_functional_style_cast_highlighting = none

1
dlls/common/Config.toml Normal file
View File

@ -0,0 +1 @@
[kernelx]

View File

@ -0,0 +1,3 @@
LIBRARY common
EXPORTS
XMemAlloc = XMemAlloc_X @504

1
dlls/common/common.h Normal file
View File

@ -0,0 +1 @@
#pragma once

164
dlls/common/common.vcxproj Normal file
View File

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{da57f1d7-7922-44cb-9251-4d0f7e5e4096}</ProjectGuid>
<RootNamespace>common</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;COMMON_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;COMMON_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;COMMON_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;COMMON_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="common.h" />
<ClInclude Include="logfmtxx.hpp" />
<ClInclude Include="toml.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="Config.toml" />
<None Include="Exports.def.bak" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="Exports.def.bak" />
<None Include="Config.toml" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="common.h" />
<ClInclude Include="toml.hpp" />
<ClInclude Include="logfmtxx.hpp" />
</ItemGroup>
</Project>

9
dlls/common/dllmain.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <Windows.h>
#include "logfmtxx.hpp"
#include "toml.hpp"
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}

177
dlls/common/logfmtxx.hpp Normal file
View File

@ -0,0 +1,177 @@
#pragma once
#pragma once
#include <type_traits>
#include <concepts>
#include <functional>
#include <utility>
#include <chrono>
#include <vector>
#include <iomanip>
#include <sstream>
#include <string>
namespace logfmtxx {
enum class level {
debug,
info,
warn,
error
};
namespace details {
template <typename T>
concept as_string_trait = requires(T t) {
{ t.as_string( ) } -> std::same_as<std::string>;
};
template <typename T>
concept serializable_trait = (
std::is_convertible_v<T, std::string>
|| as_string_trait<T>
|| std::is_arithmetic_v<T>
|| std::is_same_v<T, std::chrono::system_clock::time_point>
|| std::is_same_v<T, level>
);
template <serializable_trait T>
std::string serialize(const T& value) {
if constexpr (std::is_convertible_v<T, std::string>) {
auto stream = std::ostringstream{};
stream << std::quoted(value);
return stream.str( );
}
else if constexpr (as_string_trait<T>) {
auto stream = std::ostringstream{};
stream << std::quoted(value.as_string( ));
return stream.str( );
}
else if constexpr (std::is_arithmetic_v<T>) {
return std::to_string(value);
}
else if constexpr (std::is_same_v<T, std::chrono::system_clock::time_point>) {
auto time = std::chrono::system_clock::to_time_t(value);
auto stream = std::ostringstream{};
stream << std::put_time(std::gmtime(&time), "%Y-%m-%dT%H:%M:%SZ");
return stream.str( );
}
else if constexpr (std::is_same_v<T, level>) {
switch (value) {
case level::debug: return "debug";
case level::info: return "info";
case level::warn: return "warn";
case level::error: return "error";
}
}
return "";
}
using field_kv_type = std::pair<std::string, std::string>;
struct record {
level lvl;
std::chrono::system_clock::time_point ts;
std::string msg;
field_kv_type* global_ctx;
std::size_t global_ctx_size;
field_kv_type* local_ctx;
std::size_t local_ctx_size;
};
}
template <details::serializable_trait T>
struct field {
std::string key;
T value;
};
template <typename T>
concept printer_trait = requires(T t, const std::string & msg) {
{ t(msg) };
};
template <
typename clock_type = std::chrono::system_clock,
printer_trait printer_type = std::function<void(const std::string&)>
>
class logger {
public:
template <typename... Args>
logger(
printer_type printer,
field<Args>... fields
) : m_printer(printer) {
m_extras.reserve(sizeof...(Args));
(m_extras.push_back({ fields.key, details::serialize(fields.value) }), ...);
}
template <typename... Args>
void log(level level, const std::string& message, field<Args>... fields) {
auto record = details::record{
.lvl = level,
.ts = clock_type::now( ),
.msg = message,
.global_ctx = m_extras.data( ),
.global_ctx_size = m_extras.size( )
};
std::array<details::field_kv_type, sizeof...(Args)> local_ctx = {
details::field_kv_type{fields.key, details::serialize(fields.value)}...
};
record.local_ctx = local_ctx.data( );
record.local_ctx_size = local_ctx.size( );
m_printer(format(record));
}
template <typename... Args>
void debug(const std::string& message, field<Args>... fields) {
log(level::debug, message, fields...);
}
template <typename... Args>
void info(const std::string& message, field<Args>... fields) {
log(level::info, message, fields...);
}
template <typename... Args>
void warn(const std::string& message, field<Args>... fields) {
log(level::warn, message, fields...);
}
template <typename... Args>
void error(const std::string& message, field<Args>... fields) {
log(level::error, message, fields...);
}
private:
std::string format(const details::record& record) {
auto stream = std::ostringstream{};
stream << "time=" << details::serialize(record.ts) << " ";
stream << "level=" << details::serialize(record.lvl) << " ";
stream << "message=" << std::quoted(record.msg);
for (auto i = 0; i < record.global_ctx_size; ++i) {
const auto& [key, value] = record.global_ctx[ i ];
stream << " " << key << "=" << value;
}
for (auto i = 0; i < record.local_ctx_size; ++i) {
const auto& [key, value] = record.local_ctx[ i ];
stream << " " << key << "=" << value;
}
return stream.str( );
}
private:
printer_type m_printer;
std::vector<details::field_kv_type> m_extras;
};
}

17897
dlls/common/toml.hpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,8 @@
#pragma once
#include <winrt/Windows.ApplicationModel.h>
#include "CoreApplicationWrapperX.h"
/* This function is used to compare the class name of the classId with the classIdName. */
inline bool IsClassName(HSTRING classId, const char* classIdName)
{
@ -66,9 +64,6 @@ inline HRESULT STDMETHODCALLTYPE GetForCurrentThreadCoreApplication_Hook(ICoreAp
return hrApp;
}
/* Hook for the WinRT RoGetActivationFactory function. */
inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, void** factory)
{