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

Add logging to Konstraint output #171

Merged
merged 3 commits into from
Jun 8, 2021
Merged

Add logging to Konstraint output #171

merged 3 commits into from
Jun 8, 2021

Conversation

jalseth
Copy link
Collaborator

@jalseth jalseth commented Jun 4, 2021

This adds logging output to Konstraint as it processes policies. Debug level is used only for more verbose output, Info is used when Konstraint takes non-default paths due to user configuration as well as status updates for major steps, and Warn is used when Konstraint takes non-default paths due to implicit configurations that the user may not be aware of.

Fixes #170

Examples:

$ ./build/konstraint --log-level info doc examples -o examples/policies.md --no-rego
INFO[0000] no-rego flag is set. policy source will not be included in the documentation 
WARN[0000] no kind matchers set, this can lead to poor policy performance  name=RequiredLabels src=examples/required-labels/src.rego
INFO[0000] completed successfully                        num_policies=23
$ ./build/konstraint create examples                  
WARN[0000] skipping constraint generation due to use of parameters  name=RequiredLabels src=examples/required-labels/src.rego
INFO[0000] completed successfully                        num_policies=20

@jalseth jalseth requested a review from jpreese June 4, 2021 22:23
@jpreese
Copy link
Collaborator

jpreese commented Jun 4, 2021

LGTM, have a highly opinionated thought:

I would make all logging on by default (Info and Warn) which would mean also removing the --log-level flag and Debug outputs. I tend to go for the simple case first, and if we find a reason to require debugging, add it in a future release.

@jalseth
Copy link
Collaborator Author

jalseth commented Jun 8, 2021

Usually I prefer giving users flexibility... but I cannot imagine an actual use case for what the debug logs are currently doing so I removed them as it simplifies the PR quite a bit.

@jalseth jalseth merged commit 2ae74d9 into plexsystems:main Jun 8, 2021
@jalseth jalseth deleted the add-logging branch June 8, 2021 23:39
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.

Add logging
2 participants