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

devonfw / IDEasy / 13788808942

11 Mar 2025 01:08PM UTC coverage: 66.998% (-1.6%) from 68.619%
13788808942

Pull #1017

github

web-flow
Merge 2597874a1 into 2cf68279f
Pull Request #1017: #404: enhance logging with custom slf4j bridge

3034 of 4951 branches covered (61.28%)

Branch coverage included in aggregate %.

7831 of 11266 relevant lines covered (69.51%)

3.03 hits per line

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

85.29
cli/src/main/java/com/devonfw/tools/ide/log/IdeSubLoggerOut.java
1
package com.devonfw.tools.ide.log;
2

3
import java.io.IOException;
4

5
/**
6
 * Default implementation of {@link IdeSubLogger} that can write to an {@link Appendable} such as {@link System#out} or in case of testing a
7
 * {@link java.io.StringWriter}.
8
 */
9
public class IdeSubLoggerOut extends AbstractIdeSubLogger {
10

11
  private final Appendable out;
12

13
  /**
14
   * The constructor.
15
   *
16
   * @param level the {@link #getLevel() log-level}.
17
   * @param out the {@link Appendable} to {@link Appendable#append(CharSequence) write} log messages to.
18
   * @param colored - {@code true} for colored output according to {@link IdeLogLevel}, {@code false} otherwise.
19
   * @param minLogLevel the minimum log level (threshold).
20
   * @param listener the {@link IdeLogListener} to listen to.
21
   */
22
  public IdeSubLoggerOut(IdeLogLevel level, Appendable out, boolean colored, IdeLogLevel minLogLevel, IdeLogListener listener) {
23

24
    super(level, colored, IdeLogExceptionDetails.of(level, minLogLevel), listener);
8✔
25
    if (out == null) {
2!
26
      // this is on of the very rare excuses where System.out or System.err is allowed to be used!
27
      if (level == IdeLogLevel.ERROR) {
3✔
28
        this.out = System.err;
4✔
29
      } else {
30
        this.out = System.out;
4✔
31
      }
32
    } else {
33
      this.out = out;
×
34
    }
35
  }
1✔
36

37
  @Override
38
  public void doLog(String message, Throwable error) {
39

40
    try {
41
      String startColor = null;
2✔
42
      if (this.colored) {
3!
43
        startColor = this.level.getStartColor();
4✔
44
        if (startColor != null) {
2✔
45
          this.out.append(startColor);
5✔
46
        }
47
      }
48
      if (error != null) {
2✔
49
        message = this.exceptionDetails.format(message, error);
6✔
50
      }
51
      this.out.append(message);
5✔
52
      if (startColor != null) {
2✔
53
        this.out.append(this.level.getEndColor());
7✔
54
      }
55
      this.out.append("\n");
5✔
56
    } catch (IOException e) {
×
57
      throw new IllegalStateException("Failed to log message: " + message, e);
×
58
    }
1✔
59
  }
1✔
60
}
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