Skip to content

feat(logs): Extend logging on generated files #2700

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

Merged

Conversation

kamil-bielecki-bosch
Copy link

@kamil-bielecki-bosch kamil-bielecki-bosch commented May 12, 2025

This commit extends logging on generated configuration files:

  • .gitconfig
  • .git-credentials
  • .netrc
  • .npmrc
  • .yarnrc.yml
  • NuGet.Config
  • settings.xml (Maven)

It helps on debug / troubleshooting when it's uncertain if file was generated, and what settings it contains.

val serviceUrl = URI.create(url).toURL()
val serviceUrl = URI.create(url).toURL()

val githubCredentials = buildString {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: The variable name is misleading. This is not related to GitHub, but a plain Git configuration file. Maybe just entry.

Choose a reason for hiding this comment

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

Addressed

append(serviceUrl.protocol)
append("://")
append(builder.secretRef(usernameSecret, ConfigFileBuilder.urlEncoding)).append(':')
append(builder.secretRef(passwordSecret, ConfigFileBuilder.urlEncoding)).append('@')
append(serviceUrl.authority)
append(serviceUrl.path)
}

logger.debug(
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to have a generic logEntry function in the builder that expects a string for the entry, the file name, and the service to make sure that all logs follow a similar structure? For instance, if it is decided to log different properties for a service, there is only a single place that needs to change.

Choose a reason for hiding this comment

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

Done.

serviceUrl.path,
GIT_CREDENTIALS_FILE_NAME,
name,
organization,
Copy link
Contributor

Choose a reason for hiding this comment

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

Logging the full organization and product with all properties is probably too much. If this information is relevant at all, it should be sufficient to print only the name (if it is not null).

Choose a reason for hiding this comment

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

Done

@@ -69,6 +83,7 @@ class GitCredentialsGenerator : EnvironmentConfigGenerator<EnvironmentServiceDef
EnvironmentServiceDefinition::class.java

override suspend fun generate(builder: ConfigFileBuilder, definitions: Collection<EnvironmentServiceDefinition>) {
logger.info("Generating content of {} file.", builder.getFileInUserHome(GIT_CREDENTIALS_FILE_NAME).absoluteFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

This log statement is redundant, since the builder already logs all files that it generates. Same for the other files.

Choose a reason for hiding this comment

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

Removed

* License-Filename: LICENSE
*/

package common.env
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong package.

Choose a reason for hiding this comment

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

Fixed


import org.slf4j.LoggerFactory

internal object GeneratorLogger {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some documentation what this class is supposed to do.

Choose a reason for hiding this comment

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

Short desc added

@kamil-bielecki-bosch kamil-bielecki-bosch force-pushed the extend-config-files-logging branch from 24f4cc2 to 3b30072 Compare May 13, 2025 15:19
This commit extends logging on generated configuration files:
- .gitconfig
- .git-credentials
- .netrc
- .npmrc
- .yarnrc.yml
- NuGet.Config
- settings.xml (Maven)
It helps on debug / troubleshooting when it's uncertain if file
was generated, and what settings it contains.

Signed-off-by: Kamil Bielecki <[email protected]>
@oheger-bosch oheger-bosch added this pull request to the merge queue May 14, 2025
Merged via the queue into eclipse-apoapsis:main with commit 8555033 May 14, 2025
30 checks passed
@oheger-bosch oheger-bosch deleted the extend-config-files-logging branch May 14, 2025 05:20
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.

2 participants