Skip to content

JSON logging cleanup #3881

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

Merged
merged 14 commits into from
May 22, 2024
Merged

JSON logging cleanup #3881

merged 14 commits into from
May 22, 2024

Conversation

goodlyrottenapple
Copy link
Contributor

@goodlyrottenapple goodlyrottenapple commented May 20, 2024

emitEquationTrace term eq.attributes.location eq.attributes.ruleLabel eq.attributes.uniqueId res
handler
(\t -> setChanged >> pure t)
( \t -> setChanged >> (withContext (LogContext eq) $ withContext "success" $ withTermContext t $ pure t)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change. I think it fixes a bug in logging that I've found but haven't got to report yet.
The bug was that we would not emit 'success' messages for individual equations, and instead only emit a single 'success' message at the very end after attempting/applying all equations.

Comment on lines 58 to 60
"log-simplify-json")
SERVER="${KORE_RPC_BOOSTER} --log-format json -l Simplify --log-file test-$name/simplify-log.txt" ./runDirectoryTest.sh test-$name $@
;;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made several changes here, including adding the conversion from the original custom log levels tot he context filtering. Also renamed --simplification-log-file to just --log-file

, ("SimplifyKore", "Log all simplification in kore-rpc")
, ("SimplifySuccess", "Log successful simplifications (booster and kore-rpc)")
, ("Depth", "Log the current depth of the state")
, ("SMT", "Log the SMT-solver interactions")
, ("ErrorDetails", "Log error conditions with extensive details")
]

levelToContext :: Map Text [ContextFilter]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here are some of the common log filter we may want. Let me know if you think we should add any other ones

@goodlyrottenapple goodlyrottenapple marked this pull request as ready for review May 21, 2024 14:37
@@ -860,13 +808,15 @@ applyEquations theory handler term = do
processEquations [] =
pure term -- nothing to do, term stays the same
processEquations (eq : rest) = do
res <- applyEquation term eq
res <- withRuleContext eq $ applyEquation term eq
emitEquationTrace term eq.attributes.location eq.attributes.ruleLabel eq.attributes.uniqueId res
Copy link
Contributor

@geo2a geo2a May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that -l SImplify is re-implemented through the contextual logging, and the simplification RPC traces are to be remove in a pending PR, we are fee to drop the calls to emitEquationTrace, and the function itself too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to leave that for another pr, because we actually still log via the old logger interface within this function. Until we migrate our tools to contextual logging these may still be necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, let's keep it for now.

Copy link
Member

@jberthold jberthold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the comment about emitEquationTrace , I understand that you planned to follow up with another PR? Then we can merge this and leave the following to the next iteration:

  • There is some (more) dead code left to clean up
  • The context-log replacement for -l Aborts needs some more attention
  • Generally we should remove all old-style customLevels that have a replacement. This probably means removing most levels, except the Abort one as it is now. Once that is addressed, the levelFilter can just handle the standard Error,Warn,Info levels (but we should rather remove those, too).

Comment on lines 215 to 219
( "Aborts"
,
[ [ctxt| booster|kore>match,abort |]
]
)
Copy link
Member

@jberthold jberthold May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-l Aborts does something different than log aborted matching, it reports any condition that leads to an aborted result:

  • uncertain match
  • uncertain conditions
  • match of a rule that might not preserve definedness

In addition, it outputs the diff before and after kore-rpc simplification in (internal and external) simplify requests.

We could introduce an extra thing for the diff (there is no rigid use case for it), but we should make sure the logs for aborted rewrites have the same information as before so we can use them in the analysis script.

@@ -1,3 +1,4 @@
{-# LANGUAGE QuasiQuotes #-}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎 🆒

logLevelToKoreLogEntryMap =
Map.fromList
[ (LevelOther "SimplifyKore", ["DebugAttemptEquation", "DebugTerm"])
, (LevelOther "SimplifyJson", ["DebugAttemptEquation", "DebugTerm"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is dead code. kore-rpc-dev has another copy of it which is still used (maybe not for a good reason, though?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still need to pass these (e.g. DebugAttemptEquation) to actually get context logging in the old backend, because it has multiple layers of filtering. We could just enable all of them tho...

Comment on lines -265 to -267
getKoreEntriesForLevel :: LogLevel -> [Text.Text]
getKoreEntriesForLevel level = concat . maybeToList $ Map.lookup level logLevelToKoreLogEntryMap

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably makes the logLevelToKoreLogEntryMap dead code here, too.

@goodlyrottenapple goodlyrottenapple merged commit e62fba2 into master May 22, 2024
7 checks passed
@goodlyrottenapple goodlyrottenapple deleted the sam/json-logging-rpc-test branch May 22, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Context logging: Migrate and clean up obsolete log levels Context Logging: Shortcut options to select common context log subsets
3 participants