Files
ClassicAPI/src/debug/Log.h
T
Brues d9102bae3b Relicense source headers from LGPL to GPL v3
The repo was internally inconsistent: the LICENSE file is GPL v3 but every
src/ header carried the LGPL v3 notice and the README said "LGPL v3 or
later". LGPL was also the wrong fit — this is an injected mod plus a
bundled addon, not a library other code links against, so LGPL's linking
exception buys nothing.

It's also required: src/voicechat/Tts.cpp is ported from awesome_wotlk's
VoiceChat.cpp, which is GPL v3, and a derivative of GPL code cannot be
relicensed under more permissive terms. Dependencies stay compatible —
MinHook (BSD-2) and the nampower-mirrored packet shapes (BSD) are
GPL-compatible, and SAPI is covered by the system-library exception.

Swept "GNU Lesser General Public License" -> "GNU General Public License"
across all 257 src/ headers and changed the README license line to match
the GPL v3 LICENSE file. Comment-only; no build impact.
2026-06-29 16:38:16 -05:00

70 lines
2.8 KiB
C++

// This file is part of ClassicAPI.
//
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// ClassicAPI is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <cstdint>
// Persistent debug log shared by all probe / tracing modules. Writes
// to `C:\Git\ClassicAPI\debug.log` so it can be read directly from
// the repo by tooling/agents — the file is gitignored. Used during
// offset-finding sessions, runtime tracing of unfamiliar code paths,
// post-mortem inspection, and anywhere `OutputDebugString` would be
// awkward to capture.
//
// Three writing primitives:
// Append(label, content) — labeled block (good for snapshot diffs)
// Printf(fmt, ...) — one-line trace, no label
// HexDump(label, ptr,
// len, base) — hex+ASCII dump of a memory range, SEH-
// wrapped so faulting reads don't crash
// the host process; `base` is the address
// shown in the offset column (defaults to
// the actual VA of `ptr`).
//
// And `Clear()` to truncate before a fresh session.
namespace Debug::Log {
// Truncates the debug log file. Safe to call before any writer.
void Clear();
// Appends a labeled block. Format:
// === <label> ===
// <content>
// <blank line>
//
// Both args are nul-terminated C strings; either may be nullptr.
// `content` is written verbatim — caller controls layout.
void Append(const char *label, const char *content);
// Appends a single line (no label, no surrounding blank line).
// Auto-appends '\n' if `fmt` doesn't end with one. printf-style
// formatting; capped at ~2KB per call.
void Printf(const char *fmt, ...);
// Hex-dumps `len` bytes starting at `ptr`, formatted xxd-style with
// 16 bytes per row, both hex and ASCII columns. The offset column
// shows `base + i` — pass `base = (uintptr_t)ptr` to display real
// addresses, or `base = 0` to get pure relative offsets.
//
// SEH-wrapped: if the read faults partway through (page boundary,
// freed memory, etc.), the dump stops at the last successful row
// and notes the failed offset. Safe to call with any pointer.
void HexDump(const char *label, const void *ptr, int len, uintptr_t base);
// Convenience: HexDump with `base = (uintptr_t)ptr`.
void HexDump(const char *label, const void *ptr, int len);
} // namespace Debug::Log