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

Custom Log Formatting #3537

Merged
merged 31 commits into from
Nov 18, 2024
Merged

Custom Log Formatting #3537

merged 31 commits into from
Nov 18, 2024

Conversation

levkohimins
Copy link
Contributor

@levkohimins levkohimins commented Nov 7, 2024

Description

The PR adds two flags:

  • --terragrunt-log-format [bare | pretty | json | keyvalue]
  • --terragrunt-log-custom-format "%time %level %prefix %msg"

Context

https://linear.app/gruntwork/issue/TG-419/support-deep-log-format-customization

Closes #3431

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added / Removed / Updated [X].

Migration Guide

@levkohimins levkohimins marked this pull request as ready for review November 12, 2024 21:30
@levkohimins levkohimins requested a review from yhakbar November 12, 2024 21:31
Copy link
Collaborator

@yhakbar yhakbar left a comment

Choose a reason for hiding this comment

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

Requesting changes early.

I've only reviewed the docs stuff, but they look really good. There's so much detail, and the examples really help explain what's going on.

Great job!

docs/_docs/02_features/custom-log-format.md Outdated Show resolved Hide resolved
docs/_docs/02_features/custom-log-format.md Outdated Show resolved Hide resolved
docs/_docs/02_features/custom-log-format.md Outdated Show resolved Hide resolved
docs/_docs/02_features/custom-log-format.md Outdated Show resolved Hide resolved
docs/_docs/02_features/custom-log-format.md Outdated Show resolved Hide resolved
docs/_docs/02_features/custom-log-format.md Outdated Show resolved Hide resolved
docs/_docs/02_features/custom-log-format.md Outdated Show resolved Hide resolved
docs/_docs/02_features/custom-log-format.md Outdated Show resolved Hide resolved
docs/_docs/02_features/custom-log-format.md Outdated Show resolved Hide resolved
docs/_docs/04_reference/cli-options.md Outdated Show resolved Hide resolved
@levkohimins levkohimins self-assigned this Nov 13, 2024
@@ -128,7 +129,7 @@ type TerragruntOptions struct {
// Disable Terragrunt colors
DisableLogColors bool

// Output Terragrunt logs in JSON format
// Output Terragrunt logs in JSON formatter
Copy link
Collaborator

Choose a reason for hiding this comment

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

Format was right here. Is this an accidental find and replace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, that was by accident when I made a replacement throughout the code.

}
}

func (color *gradientColor) Value(text string) ColorValue {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not following how this is implemented, but probably just because I'm bad at golang.

Can you confirm that this will result in color transitioning from one color to another, like this?
https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Linear-gradient.svg/640px-Linear-gradient.svg.png

Do not implement this now, but I wonder if in the future we could have a user specify what the start and end colors would be.

Copy link
Contributor Author

@levkohimins levkohimins Nov 18, 2024

Choose a reason for hiding this comment

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

We already discussed this in a call conversation. This can works as gradient, we need just to fill the slice with gradient colors.

docs/_docs/02_features/custom-log-format.md Show resolved Hide resolved
**Environment Variable**: `TERRAGRUNT_LOG_CUSTOM_FORMAT`<br/>
**Requires an argument**: `--terragrunt-log-custom-format <LOG_CUSTOM_FORMAT>`<br/>

This allows you to specify which information you want to output. It works a little bit like printf format.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This allows you to specify which information you want to output. It works a little bit like printf format.
This allows you to customize logging however you like.

return func(logger *logger) {
logger.Logger.SetFormatter(formatter)
logger.Logger.SetFormatter(&logruFormatter{Formatter: formatter})
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm confused by this. Why is this called logruFormatter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a typo. Fixed and added a comment.

@levkohimins levkohimins requested a review from yhakbar November 18, 2024 18:26
@levkohimins levkohimins merged commit d8adfda into main Nov 18, 2024
4 of 5 checks passed
@levkohimins levkohimins deleted the feat/custom-log-format branch November 18, 2024 20:48
@levkohimins
Copy link
Contributor Author

Resolved in v0.68.15 release.

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.

Simplify maintaining pre 0.67.0 output format
2 participants