Skip to content

Commit a7cf443

Browse files
committed
Unwrap EnvironmentAttributeKey for logging
1 parent 6313533 commit a7cf443

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
_No unreleased changes_
1111

12+
## [3.0.0-pre14] - 2024-11-21
13+
14+
### Added
15+
- Unwrap EnvironmentAttributeKey for logging by @TimLariviere
16+
1217
## [3.0.0-pre13] - 2024-11-21
1318

1419
### Added
@@ -182,8 +187,9 @@ _No unreleased changes_
182187
### Changed
183188
- 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)
184189

185-
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre13...HEAD
186-
[3.0.0-pre12]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre13
190+
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre14...HEAD
191+
[3.0.0-pre14]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre14
192+
[3.0.0-pre13]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre13
187193
[3.0.0-pre12]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre12
188194
[3.0.0-pre11]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre11
189195
[3.0.0-pre10]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre10

src/Fabulous/Builders.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =
138138
let attr =
139139
{ Key = key
140140
#if DEBUG
141-
DebugName = $"Environment.{key}"
141+
DebugName = let (EnvironmentAttributeKey key) = key in "Environment." + key
142142
#endif
143143
Value = value }
144144

src/Fabulous/EnvironmentContext.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ and [<AllowNullLiteral>] EnvironmentContext(logger: Logger, inheritedContext: En
3030
null
3131
else
3232
inheritedContext.ValueChanged.Subscribe(fun args ->
33-
logger.Log(LogLevel.Debug, $"Env '{id}': Propagating '{args.Key}' change from '{args.OriginEnvId}'")
33+
logger.Log(LogLevel.Debug, let (EnvironmentAttributeKey key) = args.Key in $"Env '{id}': Propagating '{key}' change from '{args.OriginEnvId}'")
3434
valueChanged.Trigger(args))
3535

3636
new(logger: Logger) = new EnvironmentContext(logger, null)
@@ -46,7 +46,7 @@ and [<AllowNullLiteral>] EnvironmentContext(logger: Logger, inheritedContext: En
4646
ValueNone
4747

4848
member internal this.SetInternal<'T>(key: EnvironmentAttributeKey, value: 'T, fromUserCode: bool) =
49-
logger.Log(LogLevel.Debug, $"EnvironmentContext '{id}' set value '{key}' to '{value}'")
49+
logger.Log(LogLevel.Debug, let (EnvironmentAttributeKey key) = key in $"EnvironmentContext '{id}' set value '{key}' to '{value}'")
5050
let boxedValue = box value
5151
values[key] <- boxedValue
5252
valueChanged.Trigger(EnvironmentValueChanged(id, fromUserCode, key, ValueSome boxedValue))
@@ -68,7 +68,7 @@ and [<AllowNullLiteral>] EnvironmentContext(logger: Logger, inheritedContext: En
6868
let fromUserCode = defaultArg fromUserCode true
6969

7070
if values.ContainsKey(key.Key) || inheritedContext = null then
71-
logger.Log(LogLevel.Debug, $"EnvironmentContext '{id}' set value '{key.Key}' to '{value}'")
71+
logger.Log(LogLevel.Debug, let (EnvironmentAttributeKey key) = key.Key in $"EnvironmentContext '{id}' set value '{key}' to '{value}'")
7272
let boxedValue = box value
7373
values[key.Key] <- boxedValue
7474
valueChanged.Trigger(EnvironmentValueChanged(id, fromUserCode, key.Key, ValueSome boxedValue))

0 commit comments

Comments
 (0)