From 48a9df043df64887cb99e03d7613379c947d11d8 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Tue, 17 Feb 2026 11:57:52 +0100 Subject: Add configurable log level as optional CLI argument All three programs now accept an optional second argument [log-level] (trace, debug, info, warning, error, fatal) defaulting to info. The level is applied by setting the logger context pointer directly, avoiding a memory leak that would occur from overwriting the heap-allocated logger struct. Also documents the ASan leak-check workflow in CLAUDE.md. --- CLAUDE.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'CLAUDE.md') diff --git a/CLAUDE.md b/CLAUDE.md index 4135924..cabc688 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -61,7 +61,7 @@ Existing certs live in `certs/`. Only regenerate if missing. ## Running -Each program takes a single argument: a configuration file. Example config files are in `config/`. Start programs in order in separate terminals from the project root: +Each program takes a configuration file and an optional log level: ` [log-level]`. The log level defaults to `info`. Valid levels: `trace`, `debug`, `info`, `warning`, `error`, `fatal`. Example config files are in `config/`. Start programs in order in separate terminals from the project root: **1. Local Discovery Server (LDS)** @@ -163,6 +163,23 @@ Each test starts ServerLDS (port 14840) and ServerRegister (port 14841), runs Cl To add a new test case: create a directory under `tests/` with 3 config files (`server_lds.conf`, `server_register.conf`, `client_find_servers.conf`), then add a `"name;ExpectedPolicy"` entry to the `INTEGRATION_TESTS` list in `CMakeLists.txt`. +### Memory Leak Check (ASan) + +Rebuild with AddressSanitizer, then run the tests: + +```sh +cmake -B build -DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address" +cmake --build build --parallel +ASAN_OPTIONS="detect_leaks=1" ctest --test-dir build --output-on-failure +``` + +Reconfigure without the flags afterwards to return to a normal build: + +```sh +cmake -B build -DCMAKE_C_FLAGS="" -DCMAKE_EXE_LINKER_FLAGS="" +cmake --build build --parallel +``` + ## Project Structure | Path | Purpose | -- cgit v1.2.3