Add logging module with auto-prefix, route all output through Logger

Replace console.zig with logging.zig: per-module Logger with auto
[name] prefix, optional file output, and destination routing. Convert
all modules from manual [name] prefixes and global con.print to Logger
instances. Remove redundant "Module loaded" lines. Replace
OutputDebugStringA in outline/tracker with Logger. Add dpslog module
with structured combat log events (SPELL_DMG, PERIODIC, HEAL, MELEE).
Add clickthrough module and bigcursor D3D9 cursor scaling.
This commit is contained in:
MarcelineVQ
2026-03-10 13:26:45 -07:00
parent e403ee18f2
commit 0f14213b0b
21 changed files with 1058 additions and 298 deletions
+6 -3
View File
@@ -12,7 +12,7 @@
const std = @import("std");
const hook = @import("zhook");
const con = @import("../console.zig");
const logging = @import("../logging.zig");
// =============================================================================
// Windows API (project-specific - not in hook lib)
@@ -176,7 +176,7 @@ pub fn looseFilesLookup(game_path_ptr: u32, output_buffer_ptr: u32) bool {
const disk_path = loose_files.get(norm_buf[0..path.len]) orelse return false;
con.fmt("[customassets] loose hit: \"{s}\"\n", .{path});
log.fmt("loose hit: \"{s}\"\n", .{path});
if (output_buffer_ptr != 0) {
const disk_len = cStrLen(disk_path.ptr);
@@ -260,19 +260,21 @@ pub const module_name: [*:0]const u8 = "customassets";
var installed: bool = false;
var g_mutex: ?*anyopaque = null;
var g_is_hook_owner: bool = false;
var log: logging.Logger = .{};
pub fn isActive() bool {
return g_is_hook_owner;
}
pub fn installHooks() void {
con.print("[customassets] Module loaded\n");
const result = mod_mutex.acquire(module_name);
g_mutex = result.handle;
g_is_hook_owner = result.is_owner;
if (!g_is_hook_owner) return;
log = logging.Logger.open(module_name, .console);
applyGlobPatch();
applyLooseFilePatches();
looseFilesInit();
@@ -288,6 +290,7 @@ pub fn removeHooks() void {
}
if (g_is_hook_owner) {
log.close();
mod_mutex.release(&g_mutex);
}
g_is_hook_owner = false;