Repository navigation
HostLoom 0.13.0
The thirteenth release of HostLoom. Two threads run through it, both in HostLoom.Logging. The first is choosing the output format in configuration. A service moving from Serilog configured its console sink and CompactJsonFormatter in appsettings, but HostLoom.Logging took its formatter only in code, so the format could not differ between environments without a rebuild and a shared logging wrapper had to hard-code it. HostLoomLoggerOptions.Formatter now names the format, "Json" or "Clef", matched without regard to case and available as LogFormatterNames constants, and MaxExceptionLength sets the exception cap of the formatter created from the name. A new AddHostLoomLogging(IConfiguration, Action<HostLoomLoggerOptions>?) overload takes everything from configuration and writes to standard output, so "Formatter": "Clef" under HostLoom:Logging and one registration line replace a Serilog WriteTo console sink with CompactJsonFormatter. A formatter passed in code still takes precedence over the name, and the bootstrap logger honours the name too. Wrappers had no way to set defaults that configuration could override, because the configuration overloads apply their callback after binding, so they bound the options themselves and bypassed HostLoom's strict binding; HostLoomLoggerOptions.Bind(IConfiguration) now applies configuration with the same strict rules over whatever the wrapper set first. The Native AOT logging sample chooses its format from configuration, and its native binary checks the result.
The second thread is configuration and registration that were ignored without a word. The strict binder counted Enrichers and TimeProvider as known keys but could bind neither, so an enricher list under HostLoom:Logging:Enrichers passed startup and did nothing, the same silent skip that hides a Serilog enricher whose package is missing; any key under either name now fails startup and says to set it in code. A second AddHostLoomLogging call on the same service collection was deduplicated away together with its sink, formatter, and options, so a test host that registered its own sink over the application's received nothing; it now throws, and ClearProviders() before it replaces the first registration. Options are also validated when AddHostLoomLogging runs, so an out-of-range value or an unknown formatter name fails at the line that registered it instead of when logging is first resolved.
Upgrading from 0.12.0 changes behaviour an application can observe; each change is stated under Changed or Fixed. A second AddHostLoomLogging call on the same service collection throws instead of being ignored along with its sink, formatter, and options; call ClearProviders() first to replace a registration. Options are validated when AddHostLoomLogging runs, so an out-of-range value fails at that call rather than when logging is first resolved. Configuration that sets Enrichers or TimeProvider fails startup. An application that names no formatter, in configuration or in code, keeps writing JSON from the provider and CLEF from the bootstrap logger.
No package is published for the first time; the set is the same as 0.12.0. @hostloom/websocket-client is not part of this NuGet set; that package carries its own version and ships when a websocket-client-vX.Y.Z tag is published, and it has no changes since its 0.3.0 release.
Added
HostLoomLoggerOptions.Formatterchooses the output format by name, so configuration can set it:"Json"or"Clef", matched without regard to case, with the names also available asLogFormatterNamesconstants. Unset, the provider writes JSON and the bootstrap logger CLEF, as before. A formatter passed toAddHostLoomLoggingin code takes precedence over the name.MaxExceptionLengthsets the exception cap of the formatter created from the name.- An
AddHostLoomLogging(IConfiguration, Action<HostLoomLoggerOptions>?)overload that takes everything from configuration, the format included, and writes to standard output. HostLoomLoggerOptions.Bind(IConfiguration)applies configuration with the strict rules of the configuration overloads. A wrapper that sets defaults before calling it lets configuration override them, which the configuration overloads, applying their callback afterwards, cannot.
Changed
- A second
AddHostLoomLoggingcall on the same service collection throws. It used to be ignored along with its sink, formatter, and options; callClearProviders()first to replace a registration. AddHostLoomLoggingvalidates the options when it runs, so an out-of-range value fails at the registering call instead of when logging is first resolved.
Fixed
- Configuration that sets
EnrichersorTimeProviderunder the options section fails startup. The strict binder accepted both names but could bind neither, so a configured enricher list was ignored without a word.