Created
November 29, 2022 12:55
-
-
Save blair55/8b882d5056c6b0bbd32abb8df477230c to your computer and use it in GitHub Desktop.
Logging example before applying writer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let getSuperUserData (super, log: Logger) = | |
let sw = Stopwatch.StartNew() | |
let service = getService () | |
let result = service.getSuperUserDetails super | |
log.info ({| serviceElapsed = sw.ElapsedMilliseconds |}) | |
match result with | |
| Ok res -> | |
log.info ({| serviceResult = "success" |}) | |
Some res | |
| Error e -> | |
log.info ({| serviceResult = "error"; error = e |}) | |
None | |
let doWork (input, log: Logger) = | |
let sw = Stopwatch.StartNew() | |
log.info ({| userId = input.UserId |}) | |
match input.Status with | |
| Valid -> log.info ({| status = "valid" |}) | |
// ... | |
| Invalid -> log.info ({| status = "invalid" |}) | |
// ... | |
let result = | |
match input.Subscription with | |
| Basic -> None | |
| Super super -> getSuperUserData (super, log) | |
log.info ({| totalElapsed = sw.ElapsedMilliseconds |}) | |
// ... | |
result | |
[<EntryPoint>] | |
let main input = | |
let log = getLogger () | |
doWork (input, log) |> ignore | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment