-
Notifications
You must be signed in to change notification settings - Fork 44
Add JSON logging to Kore #3824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSON logging to Kore #3824
Conversation
--log-format json
to kore-rpc
--log-format=json
to kore-rpc
ca1af7e
to
03608f3
Compare
c393fa4
to
8b2ecf7
Compare
6cdaaf1
to
eaf8d16
Compare
prettyContext = | ||
\case | ||
[] -> [] | ||
xs -> ("Context" <> Pretty.colon) : (indent <$> mkContext xs) | ||
|
||
mkContext = | ||
\case | ||
[] -> [] | ||
[(doc, typeName)] -> | ||
[Pretty.hsep [Pretty.parens typeName, doc]] | ||
(doc, typeName) : xs -> (Pretty.hsep [Pretty.parens typeName, doc]) : (indent <$> (mkContext xs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess we will want to tweak this in a separate PR to resemble the booster contexts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, certainly.
failureDescription err = shortenText . Pretty.renderText . Pretty.layoutOneLine . Pretty.pretty $ err | ||
|
||
shortenText :: Text -> Text | ||
shortenText msg = Text.take 200 msg <> ("...truncated" :: Text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have this here? I notice that we still emit stuff like /* T Fn D Spa */
in kore terms. Perhaps once those are removed, we can remove this truncation without things blowing up too much?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the truncation because the golden file got to 140mb... though that was a bit too much to put into git.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3823 did not improve matters much unfortunately. I've settled on a slightly longer cutoff of 500 characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a couple of comments, looks good otherwise
Thanks @goodlyrottenapple! I'll be merging this then. As we've discussed, we should come up with a minimal test for the JSON logging. I've created an issue #3830. |
Fixes #3817
Fixes #3815
Entry
type class gets a newoneLineJson
method. Log entries will now need to implement this method if they are to be logged as JSON. The default implementation if just the type constructor name.DebugAttemptEquation
log entry gets an aoneLineJson
implementation that serialised the successful/failed equation applications in the same form as the Booster, i.e. following the RPC log format. The terms are not included to keep the log size manageable.LogSomeAction
constructor of theLogType
(a filed ofKoreLogOptions
) is repurposed. Instead of holding one log action, it now holds two, plus a predicate that specifies which log entries to log using which action. Then, themakeKoreLogger1
function uses the selector function to filter the logs, render them with the appropriate rendered (json or standard) and log them using the appropriate log action.booster/Server.hs
is modified to initializeLogSomeAction
with the appropriate log actions. If-l SimplifyJson
log level is activated, we enableDebugAttemptEquation
andDebugApplyEquation
(as before). If--simplification-log-file
is passed too, then Kore's simplification will be redirected there, otherwise they will end-up on stderr. Booster's simplilfications behave in the same way.booster/Proxy.hs
does not modify the request parameters when falling back to Kore or making internal simplify requests. We do not output logs received form Kore at-l SimplifJson
anymore: Kore will now do it itself.Example
Put simplification logs into a file
Or simply to
stderr
:where there will be prepended with
[SimplifyJson]