Add GetCombatLogPath/GetChatLogPath Lua functions, update log path globals

Register Lua functions to expose current log paths. At PLAYER_LOGIN,
overwrite COMBATLOGENABLED/CHATLOGENABLED globals with actual redirected
paths (English locale only). Update DLL_README with Lua API and logging
enable instructions.
This commit is contained in:
MarcelineVQ
2026-03-04 14:39:58 -08:00
parent 0c76c99734
commit 1bbf334958
4 changed files with 46 additions and 6 deletions
+9 -6
View File
@@ -115,15 +115,18 @@ Logs\<Realm>\<Character>\WoWCombatLog_YYYYMMDD_HHMMSS.txt
Logs\<Realm>\<Character>\WoWRawCombatLog_YYYYMMDD_HHMMSS.txt (superwow only)
```
Session markers are written as the first line of each log file:
- `COMBATLOG_SESSION: <Character> <Realm>` in combat and raw combat logs
- `CHAT_SESSION: <Character> <Realm>` in chat logs
Each new game session begins with a marker line (`COMBATLOG_SESSION` or `CHAT_SESSION`) identifying the character and realm. If a log file for the same character was written to within the last 30 minutes, the session continues into the same file instead of creating a new one.
If a log file for the same character was written to within the last 30 minutes, the session continues into the same file instead of creating a new one. This consolidates brief relogs into a single file.
Like any normal log use, logging must be enabled in-game for files to appear:
- **Combat log**: `/combatlog` in chat, or `LoggingCombat(1)` from a macro/addon
- **Chat log**: `/chatlog` in chat, or `LoggingChat(1)` from a macro/addon
Character and realm names are resolved from the character select screen when you click Enter World, so paths are ready before any logging begins. On character logout the session state resets, so the next login gets fresh paths and markers.
Lua API for addon developers:
No configuration needed, install and forget.
- `GetCombatLogPath()` -- returns the current combat log file path
- `GetChatLogPath()` -- returns the current chat log file path
No other configuration needed, install and forget.
**DLL:** `combatlog.dll`
+25
View File
@@ -14,6 +14,7 @@
const std = @import("std");
const hook = @import("zhook");
const con = @import("../console.zig");
const lua = @import("../lua.zig");
const o = @import("offsets.zig");
const sc = std.builtin.CallingConvention{ .x86_stdcall = .{} };
@@ -475,6 +476,30 @@ pub fn onShutdown() void {
restorePathPointers();
}
// =============================================================================
// Lua API — log path accessors
// =============================================================================
/// GetCombatLogPath() → string or nil
pub fn luaGetCombatLogPath(L: lua.State) callconv(.c) u32 {
if (g_combat_path_len > 0) {
lua.pushstring(L, @ptrCast(g_combat_path[0..g_combat_path_len :0]));
} else {
lua.pushnil(L);
}
return 1;
}
/// GetChatLogPath() → string or nil
pub fn luaGetChatLogPath(L: lua.State) callconv(.c) u32 {
if (g_chat_path_len > 0) {
lua.pushstring(L, @ptrCast(g_chat_path[0..g_chat_path_len :0]));
} else {
lua.pushnil(L);
}
return 1;
}
// =============================================================================
// Install / remove hooks
// =============================================================================
+8
View File
@@ -10,6 +10,14 @@ frame:RegisterEvent("PLAYER_LOGIN")
frame:SetScript("OnEvent", function()
if event == "PLAYER_LOGIN" then
DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00WeirdUtils|r v" .. WEIRDUTILS_VERSION .. " core loaded")
-- Update log path globals to show actual redirected paths (English locale only)
if GetCombatLogPath and COMBATLOGENABLED == "Combat being logged to Logs\\WoWCombatLog.txt" then
COMBATLOGENABLED = "Combat being logged to " .. GetCombatLogPath()
end
if GetChatLogPath and CHATLOGENABLED == "Chat being logged to Logs\\WoWChatLog.txt" then
CHATLOGENABLED = "Chat being logged to " .. GetChatLogPath()
end
end
end)
+4
View File
@@ -108,6 +108,10 @@ fn registerLuaFunctions() void {
if (build_opts.outline) {
registerFunction("OutlineCommand", @intFromPtr(&outline.outlineCommand));
}
if (build_opts.combatlog) {
registerFunction("GetCombatLogPath", @intFromPtr(&combatlog.luaGetCombatLogPath));
registerFunction("GetChatLogPath", @intFromPtr(&combatlog.luaGetChatLogPath));
}
if (build_opts.worldmarkers and markers.isActive()) {
// User-facing functions stay global
registerFunction("WorldMarker", @intFromPtr(&markers.luaWorldMarker));