Skip to content

Fix extra output configuration + Add ulog_event_to_cstr_colored#158

Merged
an-dr merged 10 commits into
mainfrom
bug/ulog_output_add-manual-outputs
May 22, 2026
Merged

Fix extra output configuration + Add ulog_event_to_cstr_colored#158
an-dr merged 10 commits into
mainfrom
bug/ulog_output_add-manual-outputs

Conversation

@an-dr

@an-dr an-dr commented May 10, 2026

Copy link
Copy Markdown
Owner

Fixes two bugs reported in #157:

  • ULOG_BUILD_DYNAMIC_CONFIG=0 in a config header was silently activating dynamic mode
    output_stdout_handler ignored the runtime colour configuration, always rendering with colour
  • Adds ulog_event_to_cstr_colored() - same as ulog_event_to_cstr but always includes ANSI colour codes, regardless of runtime colour config. Useful for custom output handlers that target a colour-capable terminal.

Refactors the ULOG_BUILD_* / ULOG_HAS_* derivation block:

  • Introduces *_DEFAULT constants as the single source of truth for defaults
  • Dynamic config is now resolved first; its ULOG_BUILD_* overrides are applied before the ULOG_HAS_* derivation runs - eliminating the double-compute and the #undef ULOG_HAS_* block

@an-dr an-dr force-pushed the bug/ulog_output_add-manual-outputs branch from 9e0cbac to dbc70e5 Compare May 10, 2026 09:47
an-dr and others added 8 commits May 10, 2026 17:47
…ode (issue #157, saphieron)

The old check `#ifndef ULOG_BUILD_DYNAMIC_CONFIG` treated any definition of
the macro — including `#define ULOG_BUILD_DYNAMIC_CONFIG 0` — as "activate
dynamic mode."  When a user placed that line in their ulog_config.h the
dynamic-config block forced every ULOG_HAS_* to 1, silently ignoring their
ULOG_BUILD_SOURCE_LOCATION=0 and ULOG_BUILD_LEVEL_SHORT=1 settings.

Fix: change to `#if !defined(ULOG_BUILD_DYNAMIC_CONFIG) || !(ULOG_BUILD_DYNAMIC_CONFIG)`
so that zero-valued definitions keep static mode active.

Also adds the ULOG_DYNCONFIG_INIT_* helper macros and ULOG_BUILD_DYNAMIC_*
override flags for users who genuinely run dynamic mode and want to control
the initial runtime state without calling the ulog_*_config() API at startup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…eplr)

ulog_event_to_cstr() was passing color=false unconditionally to
log_print_event(), so ANSI escape codes never reached custom handlers
even after calling ulog_color_config(true) — or when ULOG_BUILD_COLOR=1
in static mode.

Fix: pass color_config_is_enabled() instead.  In dynamic mode this reads
the runtime colour flag; in static mode it expands to the compile-time
ULOG_HAS_COLOR constant, so both paths are now consistent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add ulog_event_to_cstr_colored() for handlers that always want ANSI output
- Refactor color gating: color_print_start/end are now unconditional;
  output_stdout_handler checks color_config_is_enabled() at call site
- Move event_to_cstr_impl to private section as a shared helper
- Extend DynamicConfigTest with ulog_event_to_cstr_colored coverage
- Replace issue-named test files with test_event_to_cstr + ulog_config_color_level.h
- Bump version 7.0.3 → 7.1.0 (new public API)
@an-dr an-dr changed the title Fix outputs added via ulog_output_add ignoting build config Add ulog_event_to_cstr_colored + fix issue #157 May 22, 2026
@an-dr an-dr changed the title Add ulog_event_to_cstr_colored + fix issue #157 Fix extra output configuration + Add ulog_event_to_cstr_colored May 22, 2026
@an-dr an-dr merged commit f8e50a1 into main May 22, 2026
3 checks passed
@an-dr an-dr deleted the bug/ulog_output_add-manual-outputs branch May 22, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manual outputs added via ulog_output_add ignore build options such as ULOG_BUILD_SOURCE_LOCATION or ULOG_BUILD_LEVEL_SHORT

1 participant