Reformat markdown

This commit is contained in:
Nathan McCarty 2025-01-14 15:15:09 -05:00
parent 5a313c952f
commit b0e7c1aa91
14 changed files with 459 additions and 188 deletions

View file

@ -18,7 +18,8 @@ import System.File
### Log Levels
Basic enumeration describing log levels, we define some (hidden) utility functions for working with these.
Basic enumeration describing log levels, we define some (hidden) utility
functions for working with these.
```idris
public export
@ -79,7 +80,9 @@ levelToTag (Other k) =
### Logger effect
This is a basic data structure that captures a lazy log message (so we don't have to pay any of the costs associated with generating the log message when it is filtered)
This is a basic data structure that captures a lazy log message (so we don't
have to pay any of the costs associated with generating the log message when it
is filtered)
```idris
public export
@ -87,7 +90,8 @@ data Logger : Type -> Type where
Log : (level : Level) -> (msg : Lazy String) -> Logger ()
```
We'll also provide some basic accessors, and an `ignore` function useful for writing handlers.
We'll also provide some basic accessors, and an `ignore` function useful for
writing handlers.
```idris
export
@ -105,9 +109,13 @@ ignore (Log level msg) = ()
#### Handler
Because we know that we will only be using `logger` in an `IO` context, we aren't currently going to provide a `runLogger` or the like, instead we'll define a function, suitable for use as a `runEff` handler, that filters log messages and prints them to `stderr` over `IO`.
Because we know that we will only be using `logger` in an `IO` context, we
aren't currently going to provide a `runLogger` or the like, instead we'll
define a function, suitable for use as a `runEff` handler, that filters log
messages and prints them to `stderr` over `IO`.
In the event a log message is filtered out, it's inner message is never inspected, avoiding evaluation.
In the event a log message is filtered out, it's inner message is never
inspected, avoiding evaluation.
```idris
export
@ -121,7 +129,10 @@ 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.
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.
```idris
export