• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 15073527561

16 May 2025 04:57PM UTC coverage: 67.608% (-0.1%) from 67.707%
15073527561

Pull #1318

github

web-flow
Merge 16baa64fa into 5e3c8fc69
Pull Request #1318: #1314: add IdeContext.runWithoutLogging to temporary disable logging

3104 of 5000 branches covered (62.08%)

Branch coverage included in aggregate %.

7983 of 11399 relevant lines covered (70.03%)

3.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

3.23
cli/src/main/java/com/devonfw/tools/ide/log/IdeLogListenerBuffer.java
1
package com.devonfw.tools.ide.log;
2

3
/**
4
 * Extends {@link IdeLogListenerCollector} to buffer log events during bootstrapping and then flush them once the logger is properly configured.
5
 */
6
public class IdeLogListenerBuffer extends IdeLogListenerCollector {
4✔
7

8
  private boolean disabled;
9

10
  @Override
11
  protected boolean isActive() {
12

13
    return !this.disabled;
×
14
  }
15

16
  @Override
17
  public boolean onLog(IdeLogLevel level, String message, String rawMessage, Object[] args, Throwable error) {
18

19
    if (isActive()) {
×
20
      // buffer the log event
21
      super.onLog(level, message, rawMessage, args, error);
×
22
      // reject further processing of the log event suppressing it (so it is only cached)
23
      return false;
×
24
    } else {
25
      return true;
×
26
    }
27
  }
28

29
  /**
30
   * This method is supposed to be called once after the {@link IdeLogger} has been properly initialized.
31
   *
32
   * @param logger the initialized {@link IdeLogger}.
33
   */
34
  public void flushAndDisable(IdeLogger logger) {
35

36
    if (this.disabled) {
×
37
      assert (this.entries.isEmpty());
×
38
      return;
×
39
    }
40
    // disable ourselves from collecting further events
41
    this.disabled = true;
×
42
    // write all cached log events to the logger again for processing
43
    for (IdeLogEntry entry : this.entries) {
×
44
      logger.level(entry.level()).log(entry.error(), entry.message());
×
45
    }
×
46
    this.entries.clear();
×
47
  }
×
48

49
  /**
50
   * Re-enables the buffering of the logger so nothing gets logged and log messages are only collected until {@link #flushAndDisable(IdeLogger)} is called.
51
   *
52
   * @param threshold the {@link IdeLogLevel} acting as threshold.
53
   * @see com.devonfw.tools.ide.context.IdeContext#runWithoutLogging(Runnable, IdeLogLevel)
54
   */
55
  public void enable(IdeLogLevel threshold) {
56

57
    assert (this.disabled);
×
58
    this.threshold = threshold;
×
59
    this.disabled = false;
×
60
  }
×
61

62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc