Documentation tweaks and fixes

This commit is contained in:
Nathan McCarty 2025-01-23 00:17:19 -05:00
parent 9489721e29
commit 407149dd4a
4 changed files with 29 additions and 13 deletions

View file

@ -22,9 +22,18 @@ import System.File
Basic enumeration describing log levels, we define some (hidden) utility
functions for working with these.
The `Other n` log level is restricted to `n` greater than 4, to prevent
ambiguity between custom log levels and predefined log levels.
```idris
public export
data Level = Err | Warn | Info | Debug | Trace | Other Nat
data Level : Type where
Err : Level
Warn : Level
Info : Level
Debug : Level
Trace : Level
Other : (n : Nat) -> {auto _ : n `GT` 4} -> Level
```
<!-- idris
@ -44,7 +53,7 @@ natToLevel 1 = Warn
natToLevel 2 = Info
natToLevel 3 = Debug
natToLevel 4 = Trace
natToLevel k = Other k
natToLevel (S (S (S (S (S k))))) = Other (5 + k)
export
Eq Level where
@ -130,10 +139,8 @@ handleLoggerIO max_level x =
else pure . ignore $ x
```
Use the `WriterL "log" String` effect like a logging library. We'll provide a
few "log levels" as verbs for the effect, but no filtering is done, when logging
is enabled, all logs are always displayed, however the log level is indicated
with a colored tag.
Provide a family of effectful actions that emit log messages at the different
log levels.
```idris
export
@ -155,6 +162,10 @@ debug x = send $ Log Debug x
export
trace : Has Logger fs => Lazy String -> Eff fs ()
trace x = send $ Log Trace x
export
logAt : Has Logger fs => Level -> Lazy String -> Eff fs ()
logAt level x = send $ Log level x
```
## Choose