Skip to content

Feature/font logging - #2570

Open
swmal wants to merge 2 commits into
develop9from
feature/font-logging
Open

swmal wants to merge 2 commits into
develop9from
feature/font-logging

Conversation

@swmal

@swmal swmal commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Font logging

Adds diagnostics that explain which fonts and glyph fallbacks are chosen.

Usage

Set Logger inside ConfigureFonts. It is null by default (no logging) and cleared by Reset(). Already cached fonts are not resolved again, so set it inside the callback.

workbook.ConfigureFonts(c =>
{
    c.Logger = FontLoggerFactory.CreateTextFileLogger(new FileInfo(@"c:\fontlog.txt"));
});

CreateTextFileLogger writes one line per event (DBG/INF/WRN/ERR), overwrites an existing file and needs no disposal.

Custom logger

IFontLogger has two members: IsEnabled(FontLogSeverity), called before an event is built, and Log(FontLogEvent).

class MyLogger : IFontLogger
{
    public bool IsEnabled(FontLogSeverity s) => s >= FontLogSeverity.Warning;
    public void Log(FontLogEvent e) => Console.WriteLine(e.Message);
}

workbook.ConfigureFonts(c => c.Logger = new MyLogger());

FontLogEvent has a Message plus structured fields (Type, RequestedFont, ResolvedFont, Script, CodePoint). Implementations must be thread-safe; exceptions are swallowed. Glyphs found in the primary font are not logged.

@swmal swmal added this to the EPPlus 9.0 or later milestone Oct 9, 2026
@swmal swmal self-assigned this Oct 9, 2026
@swmal swmal added the enhancement New feature or request label Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant