-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 support to use print with a log level of choice. #4670
Comments
Hi @TweeZz 👋 And thanks for submitting this. That the For production, you'll probably want to look into decision logging. Some background on the print function and its implementation can be found in the OPA blog. |
Hi.. Thanks for your feedback. I have read the decision logging page you referred to, but did not see how we could create a 'custom' decision log entry with for example a 'debug' level. With any other programming language I have used (C++, C#, java, nodejs), there are means to add log entries with different log levels. We feel this as a missing feature.. TweeZz. ps: I'm in Stockholm at the moment for the AWS Summit :) |
Hey again! 😃
That is not a decision log entry, but the standard logger output from a
Provided you have built your bundles with a revision (commonly a git commit hash, but could be anything) that will let you identify what policy/data was loaded into OPA at the time of the decision, you should be able to replay the decision later with the same input/policy, and debug in any environment using the usual tooling.
Unless your policies rely heavily on
Right, but Rego isn't a general purpose programming language, but a purpose-built policy language. If you compare to other query languages you'll likely see many of the same characteristics there. All that said — if there's a strong case for logging something that's not easily covered by the decision log module, we obviously should look into how to improve that.
Oh, nice! Are you still around tomorrow? Feel free to drop by our office if you'd like to come by and say hi, for lunch or a beer in the afternoon. Shoot me an email at anders [at] styra.com if so :) |
Hey..
We are required by our Product & Solution Security Expert to mask out certain parts of the input. One of those being /input/attributes/request/http/headers as we do not want to full encoded token to be logged. We would however like to log certain things of the token we decode in our policy.
That is exactly our case. We have quite a few
We still feel the lack of being able to do some logging in several levels. Our policy code is quite complex and it can be really helpful to print / log certain things, also on production. |
Sure.. that sounds like decision log masking, no? :)
This is probably what you'd want then.
I'd still decision logging should cover that, but if you could provide an example where it wouldn't, that would be useful!
Yeah, leaving this open for a while to see if others want to chip in :) |
Just circling back on this, did you find some time to look into decision logging yet, @TweeZz ? |
Hey..
We are using decision log masking. We mask the complete http headers.
The http headers contain an encoded token. We would like to log certain claims of the decoded token. Example:
Might be, yes. Never mind. We will work with what is available. |
Thanks for expanding on that, @TweeZz 👍 Sounds like you'd want a way to include arbitrary values in the decision log rather than having logger that prints to the console? |
Thank you for responding on my musings 😉 |
I would have another argument :) For now, I still find writing policies in rego not easy, at times confusing. It's quite a different way of writing code as I'm used to :) Am I the only one missing log level support? :) |
Hi again 😃 If you have some examples of tests like that, I'd love to take a look! There are a couple of open issues wrt having the test runner be more helpful in explaining where things went wrong, and to print the difference when assertions fail, and so on. I think there's still a lot to be done in order to help providing insights into what's going on in evaluation, and there are many options to explore here. I think part of why "traditional" logging is problematic in Rego is because just like you said, Rego is different from what you're used to. Since Rego is a declarative language, taking a logging approach from imperative languages is likely going to cause as much confusion as it helps solve. Things like rule indexing and early exit optimizations might for example have the evaluator skip entire classes of rules, and log statements that "obviously" should should print something won't ever be considered for evaluation. This is already the case with the Another (lesser) problem with "imperative" logging is that it easily leads to users making assumptions about the order of evaluation, since that's the expectation they'd bring from other (imperative) languages. You can read more on the details of the print implementation in the OPA blog. I don't think we disagree on the need to make the evaluation process more transparent, we'll just need to figure out how to best accomplish that :) For testing perhaps you'll find this little library helpful? :) |
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. |
🧹 Closing this for now as it's not likely to be implemented. Good discussion above though for anyone interested! |
What part of OPA would you like to see improved?
Currently, using 'print' uses the log 'info' log level.
We would like to be able to specify at which level a print statement should log.
Describe the ideal solution
I'm fairly new to opa. Therefore it's a bit hard to suggest how this could look like.
My intuitive suggestion would be:
print.info("This is an info log entry")
print.error("This is an error log entry")
print.debug("This is an debug log entry")
Describe a "Good Enough" solution
A good enough solution to me would be whatever syntax you come up with to allow us to print on any level of choice :)
The text was updated successfully, but these errors were encountered: