Skip to content

Commit

Permalink
feat: add Log_level.to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Dec 5, 2024
1 parent a639077 commit 0b8d5f1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/log/log_level.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ type t = Logs.level =
| Debug
[@@deriving show { with_path = false }, enum, eq, ord, serpack, twine]

let to_yojson : t -> json = function
| App -> `String "app"
| Debug -> `String "debug"
| Error -> `String "error"
| Info -> `String "info"
| Warning -> `String "warn"
(** Print in a way that can be parsed back *)
let to_string : t -> string = function
| App -> "app"
| Debug -> "debug"
| Error -> "error"
| Info -> "info"
| Warning -> "warn"

let to_yojson : t -> json = fun lvl -> `String (to_string lvl)

let of_yojson : json -> (t, string) result = function
| `String "app" -> Ok App
Expand Down

0 comments on commit 0b8d5f1

Please sign in to comment.