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

Reduce log level of test Gradle projects #3717

Merged
merged 3 commits into from
Aug 12, 2024

Conversation

adam-enko
Copy link
Member

@adam-enko adam-enko commented Jul 30, 2024

Motivation

Too many logs when using Gradle TestKit causes the tests to run slower. This is mainly because Gradle TestKit stores logs in-memory (see gradle/gradle#23965).

Reducing the amount of logging would be beneficial for two reasons:

  • The tests can run faster.
  • The logs are not cluttered with unimportant messages from other Gradle tasks. We can focus on the Dokka Generator logs.

However, reducing the log level to 'lifecycle' would mean that the Dokka Generator logs would not be reported. To work around this, I added an internal flag that can override the default log level of Dokka Generator.

The result is that the tests run faster, and test results are easier to read and verify.

Summary of changes

  • Reduce the log-level of Gradle tests to 'lifecycle' by default (this can be overridden if necessary).
  • Introduce an internal flag, dokka.internal.gradle.dokkaGenerator.logLevelOverride, in AbstractDokkaTask that can re-direct the logs of Dokka Generator to a specific level, independent from the Gradle log level.
  • Correctly enable --stacktrace on all tests, and enable it by default for all tests.

^OSIP-355

Depends on

@adam-enko adam-enko added the runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin label Jul 30, 2024
@adam-enko adam-enko changed the base branch from master to adam/feat/enable-build-cache-in-integration-tests July 30, 2024 08:24
@adam-enko adam-enko force-pushed the adam/feat/reduce-gradle-testkit-logging branch 3 times, most recently from edb72b0 to c8a1296 Compare July 31, 2024 09:24
@adam-enko adam-enko changed the title Reduce Gradle TestKit logging Reduce log level of test Gradle projects Jul 31, 2024
Base automatically changed from adam/feat/enable-build-cache-in-integration-tests to master August 1, 2024 15:01
@adam-enko adam-enko force-pushed the adam/feat/reduce-gradle-testkit-logging branch 2 times, most recently from b7010d2 to ac13a82 Compare August 5, 2024 09:46
### Motivation

Too many logs when using Gradle TestKit causes the tests to run slower. This is mainly because Gradle TestKit stores logs in-memory (see gradle/gradle#23965).

Reducing the amount of logging would be beneficial for two reasons:

- The tests can run faster.
- The logs are not cluttered with unimportant messages from other Gradle tasks. We can focus on the Dokka Generator logs.

However, reducing the log level to 'lifecycle' would mean that the Dokka Generator logs would not be reported. To work around this, I added an internal flag that can override the default log level of Dokka Generator.

The result is that the tests run faster, and test results are easier to read and verify.

### Summary of changes

- Reduce the log-level of Gradle tests to 'lifecycle' by default (this can be overridden if necessary).
- Introduce an internal flag, `dokka.internal.dokkaGenerator.logLevelOverride`, in AbstractDokkaTask that can re-direct the logs of Dokka Generator to a specific level, independent from the Gradle log level.
- Correctly enable `--stacktrace` on all tests, and enable it by default for all tests.

^OSIP-355
@adam-enko adam-enko force-pushed the adam/feat/reduce-gradle-testkit-logging branch from ac13a82 to 8cf4514 Compare August 5, 2024 13:27
@adam-enko adam-enko marked this pull request as ready for review August 5, 2024 13:51
Copy link
Collaborator

@whyoleg whyoleg left a comment

Choose a reason for hiding this comment

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

Nice, let's resolve small remarks and it's good to go

override fun accept(level: String, message: String) {
if (overrideLogger != null) {
// when an override level is set, re-route all the messages
overrideLogger.invoke(message)
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 sure how I feel (love or hate), that when overriding logger level we will print all messages (even debug), but let's try :)

@adam-enko adam-enko merged commit f0f6347 into master Aug 12, 2024
13 checks passed
@adam-enko adam-enko deleted the adam/feat/reduce-gradle-testkit-logging branch August 12, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants