-
Notifications
You must be signed in to change notification settings - Fork 385
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
Added logger package and fixed issue with API calls not being shown in DEBUG or lower log levels #2747
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2747 +/- ##
==========================================
- Coverage 86.68% 86.55% -0.14%
==========================================
Files 147 148 +1
Lines 12832 12855 +23
==========================================
+ Hits 11124 11127 +3
- Misses 1129 1149 +20
Partials 579 579
|
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 think this is the right approach, but we need to fix format strings.
logger/logger.go
Outdated
} | ||
} | ||
|
||
func convertToMap(args ...interface{}) map[string]interface{} { |
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.
Not sure if there is a better way to do this.
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 think it should be fine since we are already formatting the format string and then passing it to tflog. This function makes the method signature valid (accepts map[string]interface{}
instead of any
that we use in Go SDK)
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 don't think this is needed at all. Any extra parameters during logging are expected to be inserted into the format string. IMO, you should pass nil
as the extra argument everywhere. As is, this is not very useful, it's just a list of the arguments to the format string.
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.
Some nits, but we're getting closer.
logger/logger.go
Outdated
// if the logging is enabled based on level (which default to Info). This however isn't required here | ||
// since we use the tflog package which automatically reads from TF_LOG environment variable. |
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.
It isn't that this is not required. tflog
simply does not expose what log level is supported for a logger. If it did, we would delegate to tflog
.
logger/logger.go
Outdated
} | ||
} | ||
|
||
func convertToMap(args ...interface{}) map[string]interface{} { |
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 don't think this is needed at all. Any extra parameters during logging are expected to be inserted into the format string. IMO, you should pass nil
as the extra argument everywhere. As is, this is not very useful, it's just a list of the arguments to the format string.
@tanmay-db btw, it doesn't work for exporter :-( |
…in DEBUG or lower log levels (#2747) * add logger * fix format strings * - * - * - * - * - * - * -
Changes
Terraform never had logging configured correctly (used to log all levels irrespective of log level specified). The issue (api calls not being shown in
DEBUG
log level) surfaced because in the TF version bump to 1.20.9 which had Go SDK version bump to 0.10.0, the PR: databricks/databricks-sdk-go#426 introduced INFO as basic log level leading to debug level never being enabled even if it is passed through the environment variable.Note:
terraform apply
does not show INFO level logs by default. For thatTF_LOG=INFO
needs to be passed which I think is the expected (correct) behaviour.Tests
TF_LOG=DEBUG terraform apply
shows API calls,make test
run locallydocs/
folderinternal/acceptance