Finished replacing logging with the new system
This commit is contained in:
parent
a983644f6b
commit
495e760306
|
@ -30,7 +30,7 @@ PANEL_MODAL_OVERRIDE_CALLBACK(LoadAssemblyCallback)
|
||||||
file_view_state* FileViewState = Panel_GetStateStruct(ReturningFrom, file_view_state);
|
file_view_state* FileViewState = Panel_GetStateStruct(ReturningFrom, file_view_state);
|
||||||
gs_file_info FileInfo = FileViewState->SelectedFile;
|
gs_file_info FileInfo = FileViewState->SelectedFile;
|
||||||
|
|
||||||
LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, FileInfo.Path, &State->GlobalLog);
|
LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, FileInfo.Path, GlobalLogBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
GSMetaTag(panel_render);
|
GSMetaTag(panel_render);
|
||||||
|
|
|
@ -26,9 +26,9 @@ MessageLog_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* Render
|
||||||
ui_interface* Interface = &State->Interface;
|
ui_interface* Interface = &State->Interface;
|
||||||
ui_widget* Layout = ui_PushLayout(Interface, PanelBounds, LayoutDirection_TopDown, MakeString("Message Log Layout"));
|
ui_widget* Layout = ui_PushLayout(Interface, PanelBounds, LayoutDirection_TopDown, MakeString("Message Log Layout"));
|
||||||
|
|
||||||
ui_BeginList(Interface, MakeString("Message Log List"), 10, State->GlobalLog.EntriesCount);
|
ui_BeginList(Interface, MakeString("Message Log List"), 10, GlobalLogBuffer->EntriesCount);
|
||||||
|
|
||||||
log_buffer_iter Iter = Log_GetIter(&State->GlobalLog);
|
log_buffer_iter Iter = Log_GetIter(GlobalLogBuffer);
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
log_entry* At = Iter.At;
|
log_entry* At = Iter.At;
|
||||||
|
|
|
@ -67,24 +67,29 @@ Log_TakeNextEntry(log_buffer* Log)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
Log_PrintFVarArgs(log_buffer* Log, log_entry_type Type, char* Format, va_list Args)
|
||||||
|
{
|
||||||
|
log_entry* NextEntry = Log_TakeNextEntry(Log);
|
||||||
|
NextEntry->String.Length = 0;
|
||||||
|
NextEntry->Type = Type;
|
||||||
|
PrintFArgsList(&NextEntry->String, Format, Args);
|
||||||
|
NullTerminate(&NextEntry->String);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
OutputDebugStringA(NextEntry->String.Str);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#define Log_Message(log, fmt, ...) Log_PrintF(log, LogEntry_Message, fmt, __VA_ARGS__)
|
#define Log_Message(log, fmt, ...) Log_PrintF(log, LogEntry_Message, fmt, __VA_ARGS__)
|
||||||
#define Log_Error(log, fmt, ...) Log_PrintF(log, LogEntry_Error, fmt, __VA_ARGS__)
|
#define Log_Error(log, fmt, ...) Log_PrintF(log, LogEntry_Error, fmt, __VA_ARGS__)
|
||||||
internal void
|
internal void
|
||||||
Log_PrintF(log_buffer* Log, log_entry_type Type, char* Format, ...)
|
Log_PrintF(log_buffer* Log, log_entry_type Type, char* Format, ...)
|
||||||
{
|
{
|
||||||
log_entry* NextEntry = Log_TakeNextEntry(Log);
|
|
||||||
|
|
||||||
va_list Args;
|
va_list Args;
|
||||||
va_start(Args, Format);
|
va_start(Args, Format);
|
||||||
NextEntry->String.Length = 0;
|
Log_PrintFVarArgs(Log, Type, Format, Args);
|
||||||
NextEntry->Type = Type;
|
|
||||||
PrintFArgsList(&NextEntry->String, Format, Args);
|
|
||||||
NullTerminate(&NextEntry->String);
|
|
||||||
va_end(Args);
|
va_end(Args);
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
OutputDebugStringA(NextEntry->String.Str);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal log_buffer_iter
|
internal log_buffer_iter
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
RELOAD_STATIC_DATA(ReloadStaticData)
|
RELOAD_STATIC_DATA(ReloadStaticData)
|
||||||
{
|
{
|
||||||
GlobalDebugServices = DebugServices;
|
GlobalDebugServices = DebugServices;
|
||||||
|
GlobalLogBuffer = LogBuffer;
|
||||||
if (AppReady)
|
if (AppReady)
|
||||||
{
|
{
|
||||||
app_state* State = (app_state*)Context.MemoryBase;
|
app_state* State = (app_state*)Context.MemoryBase;
|
||||||
GlobalLogBuffer = &State->GlobalLog;
|
|
||||||
State->PanelSystem.PanelDefs = GlobalPanelDefs;
|
State->PanelSystem.PanelDefs = GlobalPanelDefs;
|
||||||
State->PanelSystem.PanelDefsCount = GlobalPanelDefsCount;
|
State->PanelSystem.PanelDefsCount = GlobalPanelDefsCount;
|
||||||
|
|
||||||
|
@ -39,8 +39,6 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
State->Transient = Context->ThreadContext.Transient;
|
State->Transient = Context->ThreadContext.Transient;
|
||||||
State->Assemblies = AssemblyArray_Create(8, &State->Permanent);
|
State->Assemblies = AssemblyArray_Create(8, &State->Permanent);
|
||||||
|
|
||||||
State->GlobalLog = Log_Init(Context->ThreadContext.Allocator, 32);
|
|
||||||
|
|
||||||
State->CommandQueue = CommandQueue_Create(&State->Permanent, 32);
|
State->CommandQueue = CommandQueue_Create(&State->Permanent, 32);
|
||||||
|
|
||||||
animation_system_desc AnimSysDesc = {};
|
animation_system_desc AnimSysDesc = {};
|
||||||
|
@ -78,7 +76,7 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
|
|
||||||
State->Modes = OperationModeSystemInit(&State->Permanent, Context->ThreadContext);
|
State->Modes = OperationModeSystemInit(&State->Permanent, Context->ThreadContext);
|
||||||
|
|
||||||
ReloadStaticData(*Context, GlobalDebugServices, true);
|
ReloadStaticData(*Context, GlobalDebugServices, GlobalLogBuffer, true);
|
||||||
US_CustomInit(&State->UserSpaceDesc, State, *Context);
|
US_CustomInit(&State->UserSpaceDesc, State, *Context);
|
||||||
|
|
||||||
if (!Context->Headless)
|
if (!Context->Headless)
|
||||||
|
|
|
@ -60,7 +60,6 @@ struct app_state
|
||||||
assembly_array Assemblies;
|
assembly_array Assemblies;
|
||||||
assembly_debug_state AssemblyDebugState;
|
assembly_debug_state AssemblyDebugState;
|
||||||
animation_system AnimationSystem;
|
animation_system AnimationSystem;
|
||||||
log_buffer GlobalLog;
|
|
||||||
animation_pattern_array Patterns;
|
animation_pattern_array Patterns;
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
|
@ -92,7 +91,7 @@ LoadAssembly(gs_const_string Path, app_state* State, context Context)
|
||||||
State->Transient,
|
State->Transient,
|
||||||
Context,
|
Context,
|
||||||
Path,
|
Path,
|
||||||
&State->GlobalLog);
|
GlobalLogBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "engine/user_space.cpp"
|
#include "engine/user_space.cpp"
|
||||||
|
|
|
@ -77,7 +77,7 @@ typedef INITIALIZE_APPLICATION(initialize_application);
|
||||||
#define UPDATE_AND_RENDER(name) void name(context* Context, input_queue InputQueue, render_command_buffer* RenderBuffer, addressed_data_buffer_list* OutputData)
|
#define UPDATE_AND_RENDER(name) void name(context* Context, input_queue InputQueue, render_command_buffer* RenderBuffer, addressed_data_buffer_list* OutputData)
|
||||||
typedef UPDATE_AND_RENDER(update_and_render);
|
typedef UPDATE_AND_RENDER(update_and_render);
|
||||||
|
|
||||||
#define RELOAD_STATIC_DATA(name) void name(context Context, debug_services* DebugServices, bool AppReady)
|
#define RELOAD_STATIC_DATA(name) void name(context Context, debug_services* DebugServices, log_buffer* LogBuffer, bool AppReady)
|
||||||
typedef RELOAD_STATIC_DATA(reload_static_data);
|
typedef RELOAD_STATIC_DATA(reload_static_data);
|
||||||
|
|
||||||
#define CLEANUP_APPLICATION(name) void name(context Context, addressed_data_buffer_list* OutputData)
|
#define CLEANUP_APPLICATION(name) void name(context Context, addressed_data_buffer_list* OutputData)
|
||||||
|
|
|
@ -332,8 +332,7 @@ DebugPrint (char* Format, ...)
|
||||||
gs_string StringBuffer = MakeString(Buffer, 256);
|
gs_string StringBuffer = MakeString(Buffer, 256);
|
||||||
va_list Args;
|
va_list Args;
|
||||||
va_start(Args, Format);
|
va_start(Args, Format);
|
||||||
PrintF(&StringBuffer, Format, Args);
|
Log_PrintFVarArgs(GlobalLogBuffer, LogEntry_Message, Format, Args);
|
||||||
OutputDebugStringA(Buffer);
|
|
||||||
va_end(Args);
|
va_end(Args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +420,7 @@ ReloadAndLinkDLL(win32_dll_refresh* DLL, context* Context, gs_work_queue* WorkQu
|
||||||
if (HotLoadDLL(DLL))
|
if (HotLoadDLL(DLL))
|
||||||
{
|
{
|
||||||
SetApplicationLinks(Context, *DLL, WorkQueue);
|
SetApplicationLinks(Context, *DLL, WorkQueue);
|
||||||
Context->ReloadStaticData(*Context, GlobalDebugServices, AppReady);
|
Context->ReloadStaticData(*Context, GlobalDebugServices, GlobalLogBuffer, AppReady);
|
||||||
Success = true;
|
Success = true;
|
||||||
Log_Message(GlobalLogBuffer, "Reloaded DLL\n");
|
Log_Message(GlobalLogBuffer, "Reloaded DLL\n");
|
||||||
}
|
}
|
||||||
|
@ -586,6 +585,8 @@ WinMain (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
gs_thread_context ThreadContext = Win32CreateThreadContext();
|
gs_thread_context ThreadContext = Win32CreateThreadContext();
|
||||||
|
GlobalLogBuffer = AllocatorAllocStruct(ThreadContext.Allocator, log_buffer);
|
||||||
|
*GlobalLogBuffer = Log_Init(ThreadContext.Allocator, 32);
|
||||||
|
|
||||||
gs_allocator_debug AllocDebug = {};
|
gs_allocator_debug AllocDebug = {};
|
||||||
AllocDebug.AllocationsCountMax = 4096;
|
AllocDebug.AllocationsCountMax = 4096;
|
||||||
|
|
|
@ -54,8 +54,7 @@ PrintLastError_(char* File, u32 Line)
|
||||||
char DebugStringData[256];
|
char DebugStringData[256];
|
||||||
gs_string DebugString = MakeString(DebugStringData, 0, 256);
|
gs_string DebugString = MakeString(DebugStringData, 0, 256);
|
||||||
u32 Error = GetLastError();
|
u32 Error = GetLastError();
|
||||||
PrintF(&DebugString, "%s Line %d: Win32 Error %d\n\0", File, Line, Error);
|
Log_Error(GlobalLogBuffer, "%s Line %d: Win32 Error %d\n\0", File, Line, Error);
|
||||||
OutputDebugStringA(DebugString.Str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,9 +71,7 @@ PUSH_WORK_ON_QUEUE(Win32PushWorkOnQueue)
|
||||||
gs_string DebugString = MakeString((char*)malloc(256), 256);
|
gs_string DebugString = MakeString((char*)malloc(256), 256);
|
||||||
for (u32 i = 0; i < Queue->JobsCount; i++)
|
for (u32 i = 0; i < Queue->JobsCount; i++)
|
||||||
{
|
{
|
||||||
PrintF(&DebugString, "%d %s\n", i, Queue->Jobs[i].JobName);
|
Log_Message(GlobalLogBuffer, "%d %s \n", i, Queue->Jobs[i].JobName);
|
||||||
NullTerminate(&DebugString);
|
|
||||||
OutputDebugStringA(DebugString.Str);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
#include "../gs_libs/gs_types.h"
|
#include "../gs_libs/gs_types.h"
|
||||||
#include "../gs_libs/gs_types.cpp"
|
#include "../gs_libs/gs_types.cpp"
|
||||||
|
#include "../app/engine/foldhaus_log.h"
|
||||||
|
global log_buffer* GlobalLogBuffer;
|
||||||
|
|
||||||
#include "../app/platform_win32/win32_foldhaus_utils.h"
|
#include "../app/platform_win32/win32_foldhaus_utils.h"
|
||||||
#include "../app/platform_win32/win32_foldhaus_memory.h"
|
#include "../app/platform_win32/win32_foldhaus_memory.h"
|
||||||
#include "../app/platform_win32/win32_foldhaus_fileio.h"
|
#include "../app/platform_win32/win32_foldhaus_fileio.h"
|
||||||
|
@ -174,6 +177,8 @@ FlowerStripToChannel(u8 Flower, u8 Channel)
|
||||||
int main(int ArgCount, char** Args)
|
int main(int ArgCount, char** Args)
|
||||||
{
|
{
|
||||||
gs_thread_context Ctx = Win32CreateThreadContext();
|
gs_thread_context Ctx = Win32CreateThreadContext();
|
||||||
|
GlobalLogBuffer = AllocatorAllocStruct(Ctx.Allocator, log_buffer);
|
||||||
|
*GlobalLogBuffer = Log_Init(Ctx.Allocator, 32);
|
||||||
|
|
||||||
gs_string OutputBuffer0 = PushString(Ctx.Transient, MB(4));
|
gs_string OutputBuffer0 = PushString(Ctx.Transient, MB(4));
|
||||||
gs_string OutputBuffer1 = PushString(Ctx.Transient, MB(4));
|
gs_string OutputBuffer1 = PushString(Ctx.Transient, MB(4));
|
||||||
|
|
|
@ -6,13 +6,16 @@
|
||||||
#ifndef FIRST_CPP
|
#ifndef FIRST_CPP
|
||||||
|
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../gs_libs/gs_types.h"
|
#include "../gs_libs/gs_types.h"
|
||||||
#include "../gs_libs/gs_types.cpp"
|
#include "../gs_libs/gs_types.cpp"
|
||||||
|
#include "../app/engine/foldhaus_log.h"
|
||||||
|
global log_buffer* GlobalLogBuffer;
|
||||||
|
|
||||||
#define DEBUG_TRACK_FUNCTION
|
#define DEBUG_TRACK_FUNCTION
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
//#include "../app/foldhaus_platform.h"
|
//#include "../app/foldhaus_platform.h"
|
||||||
//#include "../gs_libs/gs_win32.cpp"
|
//#include "../gs_libs/gs_win32.cpp"
|
||||||
|
@ -92,6 +95,8 @@ CreateMessage(gs_data* Data, u8 Count)
|
||||||
int main(int ArgCount, char** Args)
|
int main(int ArgCount, char** Args)
|
||||||
{
|
{
|
||||||
gs_thread_context Ctx = Win32CreateThreadContext();
|
gs_thread_context Ctx = Win32CreateThreadContext();
|
||||||
|
GlobalLogBuffer = AllocatorAllocStruct(Ctx.Allocator, log_buffer);
|
||||||
|
*GlobalLogBuffer = Log_Init(Ctx.Allocator, 32);
|
||||||
|
|
||||||
HANDLE SerialHandle = Win32SerialPort_Open("\\\\.\\COM9", Ctx.Transient);
|
HANDLE SerialHandle = Win32SerialPort_Open("\\\\.\\COM9", Ctx.Transient);
|
||||||
Win32SerialPort_SetState(SerialHandle, 2000000, 8, 0, 1);
|
Win32SerialPort_SetState(SerialHandle, 2000000, 8, 0, 1);
|
||||||
|
|
Loading…
Reference in New Issue