Fix logging output for teleport configure commands.#38257
Conversation
567c130 to
93e71bd
Compare
| "github.com/aws/aws-sdk-go-v2/config" | ||
| "github.com/aws/aws-sdk-go-v2/service/iam" | ||
| "github.com/gravitational/trace" | ||
| log "github.com/sirupsen/logrus" |
There was a problem hiding this comment.
If we don't alias the import and require using logrus.Debugf explicitly it'd be a bit more obvious that we were using the wrong log package.
| log "github.com/sirupsen/logrus" | |
| "github.com/sirupsen/logrus" |
| ctx := context.Background() | ||
|
|
||
| // Ensure we print output to the user. LogLevel at this point was set to Error. | ||
| log.SetLevel(log.InfoLevel) |
There was a problem hiding this comment.
can't we reuse the same logger as teleport and change only if debug is set?
Not sure if users want to see info related logs when running something on cloud shell
There was a problem hiding this comment.
Yeah, I thought -d was global, but we actually don't have -d for integration commands. But I changed setting of the level to be flexible, so if the future there will be -d it will not get overwritten.
And I think showing those logs by default is helpful for the user, it tells useful information (policies names).
| } | ||
|
|
||
| log.Printf("IntegrationRole: IAM Policy %q added to Role %q\n", req.IntegrationRoleTAGPolicy, req.IntegrationRole) | ||
| logrus.Printf("IntegrationRole: IAM Policy %q added to Role %q\n", req.IntegrationRoleTAGPolicy, req.IntegrationRole) |
There was a problem hiding this comment.
Suggestion: Use Infof instead of Printf to be consistent with the rest of our logging code. Same suggestion for other commands below.
| logrus.Printf("IntegrationRole: IAM Policy %q added to Role %q\n", req.IntegrationRoleTAGPolicy, req.IntegrationRole) | |
| logrus.Infof("IntegrationRole: IAM Policy %q added to Role %q\n", req.IntegrationRoleTAGPolicy, req.IntegrationRole) |
| ctx := context.Background() | ||
|
|
||
| // Ensure we print output to the user. LogLevel at this point was set to Error. | ||
| utils.InitLogger(utils.LoggingForDaemon, slog.LevelInfo) |
* Fix logging output for 'teleport configure' commands. * Change imported log package name and don't overwrite debug level. * Use Infof() instead of Printf() * Use InitLogger to reset loglevel * Remove unneeded code.
* Fix logging output for 'teleport configure' commands. * Change imported log package name and don't overwrite debug level. * Use Infof() instead of Printf() * Use InitLogger to reset loglevel * Remove unneeded code.
* Fix logging output for 'teleport configure' commands. * Change imported log package name and don't overwrite debug level. * Use Infof() instead of Printf() * Use InitLogger to reset loglevel * Remove unneeded code.
* Fix logging output for 'teleport configure' commands. * Change imported log package name and don't overwrite debug level. * Use Infof() instead of Printf() * Use InitLogger to reset loglevel * Remove unneeded code.
* Fix logging output for 'teleport configure' commands. * Change imported log package name and don't overwrite debug level. * Use Infof() instead of Printf() * Use InitLogger to reset loglevel * Remove unneeded code.
This PR fixes printing of the log output to the user when they are running most
teleport configure ...commands. Log package used was wrong and also log level needed to be adjusted for those commands.As an alternative fix, we can just turn all
log.Printf()usage in codepath of those commands intofmt.Pritnf(), but it doesn't feel that good to usefmt.Printf()inside/lib/integrations/awsoidccode. On the other hand, log output looks better for user in that case (no INFO label and no filename:linenumber stuff at the end) and we already do it for theexternalauditstoragecommand, which I didn't touch.Changelog: Fix logging output for
teleport configure ...commands.