Skip to content

Commit d850290

Browse files
committed
Enable --log-format=json in kore-rpc
1 parent 339ec7a commit d850290

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

kore/src/Kore/Log.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import Control.Monad.Cont (
3333
ContT (..),
3434
runContT,
3535
)
36+
import Data.Aeson qualified as JSON
3637
import Data.Functor.Contravariant (
3738
contramap,
3839
)
@@ -282,6 +283,8 @@ makeKoreLogger exeName startTime timestampSwitch koreLogFormat logActionText =
282283
prettyActualEntry timestamp entry@(SomeEntry entryContext actualEntry)
283284
| OneLine <- koreLogFormat =
284285
Pretty.hsep [header, oneLineDoc actualEntry]
286+
| Json <- koreLogFormat =
287+
Pretty.hsep [header, Pretty.viaShow . JSON.encode $ oneLineJson actualEntry]
285288
| otherwise =
286289
(Pretty.vsep . concat)
287290
[ [header]

kore/src/Kore/Log/KoreLogOptions.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ instance Show KoreLogType where
181181
data KoreLogFormat
182182
= Standard
183183
| OneLine
184+
| Json
184185
deriving stock (Eq, Show)
185186

186187
instance Default KoreLogType where
@@ -204,11 +205,12 @@ parseKoreLogFormat = option formatReader info
204205
formatReader = Options.maybeReader $ \case
205206
"standard" -> Just Standard
206207
"oneline" -> Just OneLine
208+
"json" -> Just Json
207209
_ -> Nothing
208210
info =
209211
mempty
210212
<> Options.long "log-format"
211-
<> Options.help "Log format: standard, oneline"
213+
<> Options.help "Log format: standard, oneline, json"
212214
<> Options.value def
213215

214216
type EntryTypes = Set SomeTypeRep
@@ -672,6 +674,7 @@ unparseKoreLogOptions
672674

673675
koreLogFormatFlag Standard = []
674676
koreLogFormatFlag OneLine = ["--log-format=oneline"]
677+
koreLogFormatFlag Json = ["--log-format=json"]
675678

676679
timestampsSwitchFlag TimestampsEnable = ["--enable-log-timestamps"]
677680
timestampsSwitchFlag TimestampsDisable = ["--disable-log-timestamps"]

0 commit comments

Comments
 (0)