diff --git a/CHANGELOG.md b/CHANGELOG.md index bc655f4cf..931942d13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 _No unreleased changes_ +## [3.0.0-pre11] - 2024-11-16 + +### Changed +- Replaced printfn statements with Logger.Log(Debug) + ## [3.0.0-pre10] - 2024-11-14 ### Changed @@ -167,7 +172,8 @@ _No unreleased changes_ ### Changed - Fabulous.XamarinForms & Fabulous.MauiControls have been moved been out of the Fabulous repository. Find them in their own repositories: [https://github.com/fabulous-dev/Fabulous.XamarinForms](https://github.com/fabulous-dev/Fabulous.XamarinForms) / [https://github.com/fabulous-dev/Fabulous.MauiControls](https://github.com/fabulous-dev/Fabulous.MauiControls) -[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre10...HEAD +[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre11...HEAD +[3.0.0-pre11]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre11 [3.0.0-pre10]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre10 [3.0.0-pre9]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre9 [3.0.0-pre8]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre8 diff --git a/src/Fabulous/Components/Widget.fs b/src/Fabulous/Components/Widget.fs index b5aeeca06..5bea6606f 100644 --- a/src/Fabulous/Components/Widget.fs +++ b/src/Fabulous/Components/Widget.fs @@ -26,7 +26,7 @@ module Component' = | Some attr -> attr.Value :?> ComponentData | None -> failwith "Component widget must have a body" - let envContext = new EnvironmentContext(envContext) + let envContext = new EnvironmentContext(treeContext.Logger, envContext) let context = new ComponentContext() let comp = new Component(Data.Key, envContext, treeContext, context, data.Body) let struct (node, view) = comp.CreateView(ValueSome widget) @@ -47,7 +47,7 @@ module Component' = | Some attr -> attr.Value :?> ComponentData | None -> failwith "Component widget must have a body" - let envContext = new EnvironmentContext(envContext) + let envContext = new EnvironmentContext(treeContext.Logger, envContext) let context = new ComponentContext() let comp = new Component(Data.Key, envContext, treeContext, context, data.Body) let node = comp.AttachView(widget, view) diff --git a/src/Fabulous/EnvironmentContext.fs b/src/Fabulous/EnvironmentContext.fs index 35c2d09fb..77b35af2b 100644 --- a/src/Fabulous/EnvironmentContext.fs +++ b/src/Fabulous/EnvironmentContext.fs @@ -14,26 +14,26 @@ type EnvironmentValueChanged(originEnvId: Guid, fromUserCode: bool, key: string, type EnvironmentKey<'T>(key: string) = member this.Key = key -and [] EnvironmentContext(inheritedContext: EnvironmentContext) = +and [] EnvironmentContext(logger: Logger, inheritedContext: EnvironmentContext) = let id = Guid.NewGuid() let values = Dictionary() let valueChanged = Event() do if inheritedContext = null then - printfn $"EnvironmentContext '{id}' created" + logger.Log(LogLevel.Debug, $"EnvironmentContext '{id}' created") else - printfn $"EnvironmentContext '{id}' created and inherited from '{inheritedContext.Id}'" + logger.Log(LogLevel.Debug, $"EnvironmentContext '{id}' created and inherited from '{inheritedContext.Id}'") let valuePropagationSubscription = if inheritedContext = null then null else inheritedContext.ValueChanged.Subscribe(fun args -> - printfn $"Env '{id}': Propagating '{args.Key}' change from '{args.OriginEnvId}'" + logger.Log(LogLevel.Debug, $"Env '{id}': Propagating '{args.Key}' change from '{args.OriginEnvId}'") valueChanged.Trigger(args)) - new() = new EnvironmentContext(null) + new(logger: Logger) = new EnvironmentContext(logger, null) member this.Id = id @@ -46,7 +46,7 @@ and [] EnvironmentContext(inheritedContext: EnvironmentContext ValueNone member internal this.SetInternal<'T>(key: string, value: 'T, fromUserCode: bool) = - printfn $"EnvironmentContext '{id}' set value '{key}' to '{value}'" + logger.Log(LogLevel.Debug, $"EnvironmentContext '{id}' set value '{key}' to '{value}'") let boxedValue = box value values[key] <- boxedValue valueChanged.Trigger(EnvironmentValueChanged(id, fromUserCode, key, ValueSome boxedValue)) @@ -66,7 +66,7 @@ and [] EnvironmentContext(inheritedContext: EnvironmentContext let fromUserCode = defaultArg fromUserCode true if values.ContainsKey(key.Key) || inheritedContext = null then - printfn $"EnvironmentContext '{id}' set value '{key.Key}' to '{value}'" + logger.Log(LogLevel.Debug, $"EnvironmentContext '{id}' set value '{key.Key}' to '{value}'") let boxedValue = box value values[key.Key] <- boxedValue valueChanged.Trigger(EnvironmentValueChanged(id, fromUserCode, key.Key, ValueSome boxedValue)) @@ -75,7 +75,7 @@ and [] EnvironmentContext(inheritedContext: EnvironmentContext interface IDisposable with member this.Dispose() = - printfn $"EnvironmentContext '{id}' disposed" + logger.Log(LogLevel.Debug, $"EnvironmentContext '{id}' disposed") if valuePropagationSubscription <> null then valuePropagationSubscription.Dispose() diff --git a/src/Fabulous/Runner.fs b/src/Fabulous/Runner.fs index 067ab56de..ba24bd339 100644 --- a/src/Fabulous/Runner.fs +++ b/src/Fabulous/Runner.fs @@ -27,8 +27,6 @@ type Runner<'arg, 'model, 'msg>(getState: unit -> 'model, setState: 'model -> un let newModel, cmd = program.Update(lastMsg.Value, model) let subs = program.Subscribe(newModel) - printfn $"Updating model. Was %A{model}, Is %A{newModel}" - setState newModel _activeSubs <- Sub.Internal.diff _activeSubs subs |> Sub.Internal.Fx.change onError dispatch