Skip to content

Comments

switch logging to slog#275

Closed
jlambert121 wants to merge 1 commit intogruntwork-io:mainfrom
jlambert121:slog
Closed

switch logging to slog#275
jlambert121 wants to merge 1 commit intogruntwork-io:mainfrom
jlambert121:slog

Conversation

@jlambert121
Copy link

Fixes #82.

Currently all logging is done via utils.Logger which just outputs logging to stdout. It would be nice to have more control over logging by silencing logging when not needed or injecting a separate logger (compatible with *slog.Logger).

There is a lot of lines of change here, but it's just creating a slog.Handler that prefixes [boilerplate] to log lines to maintain the existing look and passing an instance of the logger throughout. go is not my primary language though, any feedback is greatly appreciated!

Replaces #189

@vercel
Copy link

vercel bot commented Feb 14, 2026

@jlambert121 is attempting to deploy a commit to the Gruntwork Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Author

@jlambert121 jlambert121 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay on this, rebased from master and incorporated feedback. Let me know your thoughts!

Edit: Not sure why there are conflicts, investigating

Logger.Printf("Running command: %s %s", command, strings.Join(args, " "))
// Run the given shell command with the given environment variables and arguments in the given working directory
func RunShellCommandAndGetOutput(workingDir string, envVars []string, command string, args ...string) (string, error) {
fmt.Printf("Running command: %s %s\n", command, strings.Join(args, " "))
Copy link
Author

Choose a reason for hiding this comment

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

Not using slog, but seems like maybe it is OK for these?

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.

Implement logger with logging levels

1 participant