Releases: streamingfast/logging
Releases · streamingfast/logging
v1.2.2
Added
Registry.GetTracerByPackageID(packageID string) (*bool, bool)exposes the raw trace-enabled pointer for a registered logger, allowing external bridges (e.g. a v2 compatibility layer) to mirror trace state into v1 tracers.logging.LoggerFromContext(ctx, fallback)as the canonical replacement forlogging.Logger(ctx, fallback).
Deprecated
logging.Logger(ctx, fallback)— uselogging.LoggerFromContextinstead, or the one-liner level helperslogging.Info,logging.Debug, etc.
v1.2.1
v1.2.0
Added
GlobalRegistry() Registryexposes the global registry, allowing a future v2 module to discover and re-instantiate all loggers registered via v1PackageLogger.Registry.All(fn func(packageID, shortName string))iterates over all registered loggers in a registry, enabling cross-module migration scenarios.- Loggers registered via
PackageLoggerafterInstantiateLoggershas already been called are now immediately instantiated and have the same level rules (default level, pre-spec, env spec) applied to them.
Fixed
SetLevelFornow re-applies the current environment variable overrides (DLOG, DEBUG, TRACE, …) after setting the level, so the provided level acts as a baseline that env vars can override. This fixes the common pattern of callingSetLevelFor(".*", zap.WarnLevel, false)in a CobraPreRunhook while still allowingDLOG/DEBUG/TRACEto take effect.
Changed
- The default text
encoderuse to encode log entries now emits the level when coloring is disabled. - Deprecated
logging.IsTraceEnabled, define your logger andTracerdirectly withvar zlog, tracer = logging.PackageLogger(<shortName>, "...")instead of separately,tracer.Enabled()can then be used to determine if tracing should be enabled (can be enable dynamically). - Deprecated
logging.TestingOverride, uselogging.InstantiateLoggersdirectly. - Deprecated
logging.Overidde, uselogging.InstantiateLoggersdirectly and use thelogging.WithDefaultSpecto configure the various loggers.` instead. - Deprecated
logging.Register, usevar zlog, _ = logging.PackageLogger(<shortName>, "...")instead. - Deprecated
logging.RegisterOnUpdate, uselogging.LoggerOnUpdateinstead (will probably be removed actually entirely since it's not needed anymore). - Deprecated
logging.WithServiceName, no replacement yet (will belogging.LoggerServiceNamein a future release, if unspecifiedshortNamewill be used). - Deprecated
logging.RootLogger, uselogging.PackageLoggerand control levels vialogging.WithDefaultSpec(...)inInstantiateLoggersinstead (e.g.WithDefaultSpec("logger1=info,logger2=debug,.*=warn")). The root logger concept tried to be smart about defaulting toinfowhich caused API confusion.
Removed
- BREAKING CHANGE Removed
logging.Handler, it has been moved todtracingpackage to limit transitive depdendencies on this project, you should usedtracing.NewAddTraceIDAwareLoggerMiddlewareinstead.