Skip to content
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

Feature/logging part 1 #448

Merged
merged 2 commits into from
Feb 18, 2019
Merged

Conversation

eviefp
Copy link
Contributor

@eviefp eviefp commented Feb 11, 2019

Reviewer checklist
  • Test coverage: stack test --coverage
  • Public API documentation: stack haddock
  • Style conformance: stylish-haskell

@eviefp eviefp force-pushed the feature/logging branch 5 times, most recently from 5757fc7 to 6fa1c3f Compare February 14, 2019 14:49
@eviefp eviefp changed the title Feature/logging (NOT READY) Feature/logging part 1 Feb 14, 2019
@eviefp eviefp requested a review from ttuegel February 14, 2019 14:49
@eviefp
Copy link
Contributor Author

eviefp commented Feb 14, 2019

A few things that I did not decide on yet, but we might want to wait until there are more use-cases, although I could be convinced otherwise:

  • do we want the log functions to take Builder instead of Text?
  • what do we do about Text.pack (show pattern)? Do we need a Text (or Builder) based Show?
  • no filtering by scope yet
  • should scope be a [Text] instead of Text, in LogMessage?
  • do we want the helper log* functions or should we just say log Debug? I like the idea of importing qualified and using Log.logDebug, in which case they are needed

Dockerfile Outdated Show resolved Hide resolved
@ttuegel
Copy link
Contributor

ttuegel commented Feb 15, 2019

what do we do about Text.pack (show pattern)? Do we need a Text (or Builder) based Show?

I would recommend using the formatting library for this. Summary: you can define reusable, typed format strings and instantiate them to Text, Builder, or anything you can imagine.

should scope be a [Text] instead of Text, in LogMessage?

I would recommend newtype-ing Text (as Scope?) and taking a [Scope].

I like the idea of importing qualified and using Log.logDebug, in which case they are needed

👍, import ALL THE THINGS qualified.

@@ -18,6 +18,9 @@ To regenerate the golden data for regression tests:
`stack test --no-keep-going --ta --accept`

To generate documentation: `stack build --haddock`.
Note that because of `co-log`'s `typerep-map` dependency (which fails haddock),
we are currently building with `--no-haddock-deps`. This should be reverted
once `typerep-map`'s haddock is fixed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you open an issue on our tracker for this, and include a link to the upstream issue?

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 have, and they closed it and linked to this bug in stack: commercialhaskell/stack#3989 ; I'll add this to the docs here.

@@ -183,7 +183,7 @@ execBenchmark root kFile definitionFile mainModuleName test =
-> IO (CommonStepPattern Object)
execution (verifiedModule, purePattern) =
SMT.runSMT SMT.defaultConfig
$ evalSimplifier
$ evalSimplifier mempty
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we define a value, say emptyLogger = mempty, just to keep this clear?

Copyright : (c) Runtime Verification, 2018
License : NCSA
Maintainer : vladimir.ciobanu@runtimeverification.com
Stability : experimental
Copy link
Contributor

Choose a reason for hiding this comment

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

For this and all the other new modules, I would be inclined to leave off Stability and Portability. Stability doesn't mean anything, except it makes a tiny note in the upper right-hand corner of the generated documentation that nobody looks at. All of our Portability fields are wrong, anyway: they should say GHC-only, which is what everyone's say, or should say, so it's just noise.

@@ -123,7 +126,9 @@ transitionRule tools substitutionSimplifier simplifier =
$ stepWithRewriteRule tools substitutionSimplifier config a
case result of
Left _ -> pure []
Right results -> return $ mapMaybe (patternFromResult proof) results
Right results ->
Log.withLogScope "transitionRule" $
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we easily get a source location here? There are already multiple things called transitionRule.

@@ -7,7 +7,7 @@ Maintainer : thomas.tuegel@runtimeverification.com
-}

module SMT
( SMT, getSMT
( SMT (..)
Copy link
Contributor

Choose a reason for hiding this comment

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

I specifically want to avoid exporting the constructor here:

Suggested change
( SMT (..)
( SMT, getSMT


-- | This type should not be used directly, but rather should be created and
-- dispatched through the `log` functions.
data LogMessage = LogMessage
Copy link
Contributor

Choose a reason for hiding this comment

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

The field names here do not conform to the style guide.

@dwightguth
Copy link
Collaborator

While you are at it, can you replace --only-dependencies with --only-snapshot?

@eviefp
Copy link
Contributor Author

eviefp commented Feb 18, 2019

@ttuegel I addressed all comments. I actually need a way to go from the Simplifier :: ReaderT (..., MVar Solver) to SMT :: ReaderT (MVar Solver) so I created withSolver'. Is that better than exporting the constructor directly?

Also, I did not add the formatters library yet. I think formatting the log message is not necessarily the main problem here (it might become soon, I agree). I was actually concerned by Show pat being show because (I think?) it does a lot of concats on strings, which are slow...? So I was hoping there was a Show-like class that uses Text -- or better yet, Builder?

@ttuegel
Copy link
Contributor

ttuegel commented Feb 18, 2019

Is that better than exporting the constructor directly?

I think so.

I was actually concerned by Show pat being show because (I think?) it does a lot of concats on strings, which are slow...?

Show is actually based on shows, which returns a String-builder (String -> String), so it's not too bad actually.

So I was hoping there was a Show-like class that uses Text -- or better yet, Builder?

shows is still string-based, but I recommended formatting because you can use the same format declaration to send output to Text, Builder, String, even directly to a Handle. It does not provide a class, but I'm not sure how valuable a class would be for logging: We will always know the concrete type of the thing we are logging (no runtime instance resolution), and it is likely that different types of logging will want to represent the same information in different ways (no single-instance per type).

@eviefp
Copy link
Contributor Author

eviefp commented Feb 18, 2019

Ok, now I get it. I think I might add formatting once I get into the meat of adding debugging logs with some real use-cases, along with perhaps some variants of the log functions that take a Format as an argument. Thanks for the review!

@eviefp eviefp merged commit c5015d2 into runtimeverification:master Feb 18, 2019
@eviefp eviefp deleted the feature/logging branch February 19, 2019 12:23
= do

= Log.withLogScope "stepWithRule" $ do
Log.logDebug
Copy link
Contributor

Choose a reason for hiding this comment

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

This handles both function evaluation and rewrite rule application. There is a good chance that this will be extremely verbose for everything except trivial examples (especially since it's using show and not unparse). Also, if you want to reduce verbosity, both for rewriting and for function application, we apply a (sometimes large) number of axioms on the same pattern, so it might be better to log the pattern in this function's caller and to log only the axiom here.

@@ -0,0 +1,134 @@
{-|
Copy link
Contributor

Choose a reason for hiding this comment

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

You should include documentation about the expected usage patterns.

{-|
Module : Kore.Logger
Description : Logging functions.
Copyright : (c) Runtime Verification, 2018
Copy link
Contributor

Choose a reason for hiding this comment

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

2019

jberthold pushed a commit that referenced this pull request Apr 10, 2024
Co-authored-by: devops <devops@runtimeverification.com>
Co-authored-by: Georgy Lukyanov <mail@geo2a.info>
jberthold pushed a commit that referenced this pull request Apr 10, 2024
Co-authored-by: devops <devops@runtimeverification.com>
Co-authored-by: Georgy Lukyanov <mail@geo2a.info>
jberthold pushed a commit that referenced this pull request Apr 10, 2024
Co-authored-by: devops <devops@runtimeverification.com>
Co-authored-by: Georgy Lukyanov <mail@geo2a.info>
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.

4 participants