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:
+5
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
const hook = @import("zhook");
|
||||
const con = @import("../console.zig");
|
||||
const logging = @import("../logging.zig");
|
||||
const tracker = @import("tracker.zig");
|
||||
const model_hook = @import("model_hook.zig");
|
||||
const d3d9_hook = @import("d3d9_hook.zig");
|
||||
@@ -14,6 +14,7 @@ const WINAPI = std.builtin.CallingConvention.winapi;
|
||||
const mod_mutex = @import("../mutex.zig");
|
||||
|
||||
pub const module_name: [*:0]const u8 = "outline";
|
||||
var log: logging.Logger = .{};
|
||||
|
||||
var g_mutex: ?*anyopaque = null;
|
||||
var g_is_hook_owner: bool = false;
|
||||
@@ -27,13 +28,14 @@ pub fn isActive() bool {
|
||||
/// dummy D3D9 device during engine init corrupts the d3d9 proxy's state and
|
||||
/// causes model rendering to stutter at ~10fps.
|
||||
pub fn init() bool {
|
||||
con.print("[outline] 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 true;
|
||||
|
||||
log = logging.Logger.open(module_name, .console);
|
||||
tracker.initLogger();
|
||||
if (!model_hook.installHooks()) return false;
|
||||
return true;
|
||||
}
|
||||
@@ -50,6 +52,7 @@ pub fn cleanup() void {
|
||||
if (g_is_hook_owner) {
|
||||
d3d9_hook.removeHooks();
|
||||
model_hook.removeHooks();
|
||||
log.close();
|
||||
mod_mutex.release(&g_mutex);
|
||||
}
|
||||
g_is_hook_owner = false;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
const hook = @import("zhook");
|
||||
const logging = @import("../logging.zig");
|
||||
const wow = @import("wow.zig");
|
||||
const o = @import("offsets.zig");
|
||||
const types = @import("types.zig");
|
||||
@@ -307,11 +308,13 @@ pub const Diag = struct {
|
||||
};
|
||||
|
||||
pub var diag: Diag = .{};
|
||||
var log: logging.Logger = .{};
|
||||
|
||||
const WINAPI = std.builtin.CallingConvention.winapi;
|
||||
extern "kernel32" fn OutputDebugStringA(lpOutputString: [*:0]const u8) callconv(WINAPI) void;
|
||||
pub fn initLogger() void {
|
||||
log = logging.Logger.open("outline", .console);
|
||||
}
|
||||
|
||||
/// Log diagnostic counters via OutputDebugStringA. Called from EndScene.
|
||||
/// Log diagnostic counters. Called from EndScene.
|
||||
/// Only logs when outline activity is detected, limited to first 20 events.
|
||||
pub fn logDiagnostics(cached_draw_count: u32) void {
|
||||
const has_activity = diag.scan_targets > 0 or diag.scan_raid_marks > 0 or
|
||||
@@ -322,8 +325,7 @@ pub fn logDiagnostics(cached_draw_count: u32) void {
|
||||
if (!has_activity or diag.log_count >= 20) return;
|
||||
diag.log_count += 1;
|
||||
|
||||
var buf: [256]u8 = undefined;
|
||||
const msg = std.fmt.bufPrint(&buf, "[Outline] scan t={d} r={d} d={d} | classify t={d} r={d} d={d} | cached={d}\x00", .{
|
||||
log.fmt("scan t={d} r={d} d={d} | classify t={d} r={d} d={d} | cached={d}\n", .{
|
||||
diag.scan_targets,
|
||||
diag.scan_raid_marks,
|
||||
diag.scan_dead_players,
|
||||
@@ -331,8 +333,7 @@ pub fn logDiagnostics(cached_draw_count: u32) void {
|
||||
diag.classify_raid_mark,
|
||||
diag.classify_dead_player,
|
||||
cached_draw_count,
|
||||
}) catch return;
|
||||
OutputDebugStringA(@ptrCast(msg.ptr));
|
||||
});
|
||||
}
|
||||
|
||||
/// Reset per-frame diagnostic counters. Called at start of scanObjects.
|
||||
|
||||
Reference in New Issue
Block a user