Skip to content

Conversation

@flameJam
Copy link

@flameJam flameJam commented Dec 2, 2024

Addresses issue TS-XXXXX

  • Changes are tested adequately
  • Agent's README.md updated in case of user-visible changes
  • CHANGELOG.md updated
  • Present new features in N&N
  • TGA Tutorial updated
  • TIA Tutorial updated

Please respect the vote of the Teamscale bot or flag irrelevant findings as tolerated or false positives. If you feel that the Teamscale config needs adjustment, please state so in a comment and discuss this with your reviewer.

@flameJam
Copy link
Author

The one failing test should be fixed once merged to master.

Copy link
Contributor

@DreierF DreierF left a comment

Choose a reason for hiding this comment

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

Thank you very much @flameJam for cleaning this up!

Comment on lines 10 to 14
/**
* An appender that collects log statements in its buffer until it's asked to empty it into a given
* {@link LoggerContext}. It can be used to log log-messages before an actual logging appender has been configured using
* the options passed to the agent.
* */
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also document here how logback picks up this appender. I guess this will feel a bit to magical without further logback knowledge.

<appender name="Delayed" class="shadow.com.teamscale.jacoco.agent.logging.DelayedLogAppender">
</appender>

<root level="INFO">
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean we drop any TRACE/DEBUG messages that are logged while the usual logger is not yet attached? This might be unexpected I guess.

// StatusPrinter will handle this
}
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
DelayedLogAppender.logTo(loggerContext);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we dump the already collected logs into the new context, but do we still continue to collect logs in the DelayedLogAppender afterwards? If so this would be I problem I guess considering that we keep all of those in memory and never discard them anymore.

TeamscaleCredentials credentials = TeamscalePropertiesUtils.parseCredentials();
if (credentials == null) {
delayedLogger.warn("Did not find a teamscale.properties file!");
LOGGER.warn("Did not find a teamscale.properties file!");
Copy link
Contributor

Choose a reason for hiding this comment

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

When I run the sample-app on master with logging-config=./tmp/teamscale-jacoco-agent/logging/logback.rolling-file.xml the console output is

Picked up JAVA_TOOL_OPTIONS: -javaagent:tmp/teamscale-jacoco-agent/lib/teamscale-jacoco-agent.jar=config-file=./log-test.properties

on this branch it is

Picked up JAVA_TOOL_OPTIONS: -javaagent:tmp/teamscale-jacoco-agent/lib/teamscale-jacoco-agent.jar=config-file=./log-test.properties
16:00:35.529 [main] WARN com.teamscale.jacoco.agent.PreMain -- Did not find a teamscale.properties file!
16:00:35.531 [main] DEBUG com.teamscale.jacoco.agent.options.AgentOptionsParser -- Parsing options: config-file=./log-test.properties

which I would not have expected as the log output is expected to be written to the file system. Not 100% sure though where those logs are written to the console though.

Copy link
Author

@flameJam flameJam Dec 18, 2024

Choose a reason for hiding this comment

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

I think this was caused by the fact that the delayed appender wasn't actually used at all - I think for some reason a console logger was picked up somewhere instead? And I mistook its output for the output of the console appender that was supposed to be used after initializing the correct logger... At least in my current implementation it is not actually used when calling LOGGER.error(...) 🤔 I'm working on it

@cqse-teamscale-io
Copy link

  • agent/src/main/java/com/teamscale/jacoco/agent/PreMain.java:61-97: [Test Gap] Changed method premain has not been tested. (view in Teamscale)
  • agent/src/main/java/com/teamscale/jacoco/agent/PreMain.java:145-158: [Test Gap] Changed method initializeLogging has not been tested. (view in Teamscale)
  • agent/src/main/java/com/teamscale/jacoco/agent/PreMain.java:230-240: [Test Gap] Changed method createFallbackLoggerFromConfig has not been tested. (view in Teamscale)
  • agent/src/main/java/com/teamscale/jacoco/agent/PreMain.java:182-191: [Test Gap] Changed method initializeDebugLogging has not been tested. (view in Teamscale)
  • agent/src/main/java/com/teamscale/jacoco/agent/PreMain.java:245-248: [Test Gap] Added method logAndPrintError has not been tested. (view in Teamscale)
  • agent/src/main/java/com/teamscale/jacoco/agent/PreMain.java:99-102: [Test Gap] Added method initializeDelayedLogging has not been tested. (view in Teamscale)
  • agent/src/main/java/com/teamscale/jacoco/agent/PreMain.java:198-227: [Test Gap] Changed method initializeFallbackLogging has not been tested. (view in Teamscale)
  • agent/src/main/java/com/teamscale/jacoco/agent/PreMain.java:105-142: [Test Gap] Changed method getAndApplyAgentOptions has not been tested. (view in Teamscale)
  • agent/src/main/java/com/teamscale/jacoco/agent/configuration/ConfigurationViaTeamscale.java:53-79: [Test Gap] Changed method retrieve has not been tested. (view in Teamscale)
  • agent/src/main/java/com/teamscale/jacoco/agent/convert/ConvertCommand.java:95-99: [Test Gap] Changed method getClassDirectoriesOrZips has not been tested. (view in Teamscale)

See other 9 changed and 8 added untested methods.

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.

4 participants