0 | ||| Typed primitive values for structured log fields.
 1 | |||
 2 | ||| `LogParamValue` preserves type fidelity so that numbers remain
 3 | ||| numbers and booleans remain booleans in structured output (e.g. JSON),
 4 | ||| rather than everything being stringified.
 5 | module Log4Types.Core.Value
 6 |
 7 | %default total
 8 |
 9 | ||| A primitive value that can appear in a structured log field.
10 | public export
11 | data LogParamValue
12 |   = StrVal String
13 |   | IntVal Integer
14 |   | FloatVal Double
15 |   | BoolVal Bool
16 |   | NullVal
17 |
18 | public export
19 | Eq LogParamValue where
20 |   StrVal a   == StrVal b   = a == b
21 |   IntVal a   == IntVal b   = a == b
22 |   FloatVal a == FloatVal b = a == b
23 |   BoolVal a  == BoolVal b  = a == b
24 |   NullVal    == NullVal    = True
25 |   _          == _          = False
26 |
27 | public export
28 | Show LogParamValue where
29 |   show (StrVal s)   = show s
30 |   show (IntVal i)   = show i
31 |   show (FloatVal f) = show f
32 |   show (BoolVal b)  = show b
33 |   show NullVal      = "null"
34 |