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

devonfw / IDEasy / 22300285724

23 Feb 2026 09:32AM UTC coverage: 70.754% (+0.3%) from 70.474%
22300285724

Pull #1714

github

web-flow
Merge caa980897 into 379acdc9d
Pull Request #1714: #404: #1713: advanced logging

4064 of 6348 branches covered (64.02%)

Branch coverage included in aggregate %.

10640 of 14434 relevant lines covered (73.71%)

3.1 hits per line

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

80.88
cli/src/main/java/com/devonfw/tools/ide/log/IdeLogLevel.java
1
package com.devonfw.tools.ide.log;
2

3
import org.slf4j.Marker;
4
import org.slf4j.MarkerFactory;
5
import org.slf4j.event.Level;
6

7
/**
8
 * {@link Enum} with the available log-levels for IDEasy.
9
 *
10
 * @see Slf4jLoggerAdapter
11
 */
12
public enum IdeLogLevel {
3✔
13

14
  /** {@link IdeLogLevel} for tracing (very detailed and verbose logging). */
15
  TRACE("\033[38;5;240m", Level.TRACE, null, JulLogLevel.TRACE),
10✔
16

17
  /** {@link IdeLogLevel} for debugging (more detailed logging). */
18
  DEBUG("\033[90m", Level.DEBUG, null, JulLogLevel.DEBUG),
10✔
19

20
  /** {@link IdeLogLevel} for general information (regular logging). */
21
  INFO(null, Level.INFO, null, JulLogLevel.INFO),
10✔
22

23
  /**
24
   * {@link IdeLogLevel} for a step (logs the step name and groups the following log statements until the next step).
25
   */
26
  STEP("\033[35m", Level.INFO, MarkerFactory.getMarker("STEP"), JulLogLevel.STEP),
11✔
27

28
  /** {@link IdeLogLevel} for user interaction (e.g. questions or options). */
29
  INTERACTION("\033[96m", Level.INFO, MarkerFactory.getMarker("INTERACTION"), JulLogLevel.INTERACTION),
11✔
30

31
  /** {@link IdeLogLevel} for success (an important aspect has been completed successfully). */
32
  SUCCESS("\033[92m", Level.INFO, MarkerFactory.getMarker("SUCCESS"), JulLogLevel.SUCCESS),
11✔
33

34
  /** {@link IdeLogLevel} for a warning (something unexpected or abnormal happened but can be compensated). */
35
  WARNING("\033[93m", Level.WARN, null, JulLogLevel.WARNING),
10✔
36

37
  /**
38
   * {@link IdeLogLevel} for an error (something failed and we cannot proceed or the user has to continue with extreme care).
39
   */
40
  ERROR("\033[91m", Level.ERROR, null, JulLogLevel.ERROR),
10✔
41

42
  /** {@link IdeLogLevel} for {@link com.devonfw.tools.ide.commandlet.Commandlet#isProcessableOutput() processable output} */
43
  PROCESSABLE(null, Level.INFO, MarkerFactory.getMarker("PROCESSABLE"), JulLogLevel.PROCESSABLE);
11✔
44

45
  private final String color;
46

47
  private final Level slf4jLevel;
48

49
  private final Marker slf4jMarker;
50

51
  private final java.util.logging.Level julLevel;
52

53
  /**
54
   * The constructor.
55
   */
56
  private IdeLogLevel(String color, Level slf4jLevel, Marker slf4jMarker, java.util.logging.Level julLevel) {
4✔
57

58
    this.color = color;
3✔
59
    this.slf4jLevel = slf4jLevel;
3✔
60
    this.slf4jMarker = slf4jMarker;
3✔
61
    this.julLevel = julLevel;
3✔
62
  }
1✔
63

64
  /**
65
   * @return the prefix to append for colored output to set color according to this {@link IdeLogLevel}.
66
   */
67
  public String getStartColor() {
68

69
    return this.color;
3✔
70
  }
71

72
  /**
73
   * @return the suffix to append for colored output to reset to default color.
74
   */
75
  public String getEndColor() {
76

77
    return "\033[0m"; // reset color
2✔
78
  }
79

80
  /**
81
   * @return the Slf4J {@link Level}.
82
   */
83
  public Level getSlf4jLevel() {
84

85
    return this.slf4jLevel;
3✔
86
  }
87

88
  /**
89
   * @return the SLF4J {@link Marker}. Will be {@code null} for standard log-levels.
90
   */
91
  public Marker getSlf4jMarker() {
92

93
    return this.slf4jMarker;
3✔
94
  }
95

96
  /**
97
   * @return the JUL {@link java.util.logging.Level}.
98
   */
99
  public java.util.logging.Level getJulLevel() {
100

101
    return this.julLevel;
3✔
102
  }
103

104
  /**
105
   * @return {@code true} in case of a custom log-level, {@code false} otherwise (standard log-level supported by SLF4J and all reasonable loggers).
106
   */
107
  public boolean isCustom() {
108

109
    return (this == STEP) || (this == INTERACTION) || (this == SUCCESS) || (this == PROCESSABLE);
×
110
  }
111

112
  /**
113
   * @param marker the {@link Marker}.
114
   * @return the corresponding {@link IdeLogLevel}.
115
   */
116
  public static IdeLogLevel getLevel(Marker marker) {
117

118
    if (marker == INTERACTION.slf4jMarker) {
4✔
119
      return IdeLogLevel.INTERACTION;
2✔
120
    } else if (marker == STEP.slf4jMarker) {
4✔
121
      return IdeLogLevel.STEP;
2✔
122
    } else if (marker == SUCCESS.slf4jMarker) {
4✔
123
      return IdeLogLevel.SUCCESS;
2✔
124
    } else if (marker == PROCESSABLE.slf4jMarker) {
4✔
125
      return IdeLogLevel.PROCESSABLE;
2✔
126
    } else {
127
      return IdeLogLevel.INFO; // unknown marker
2✔
128
    }
129
  }
130

131
  /**
132
   * @param level the SLF4J log {@link Level}.
133
   * @param marker the SLF4J {@link Marker}.
134
   * @return the {@link IdeLogLevel}.
135
   */
136
  public static IdeLogLevel of(Level level, Marker marker) {
137

138
    return switch (level) {
6!
139
      case ERROR -> IdeLogLevel.ERROR;
2✔
140
      case WARN -> IdeLogLevel.WARNING;
2✔
141
      case INFO -> getLevel(marker);
3✔
142
      case DEBUG -> IdeLogLevel.DEBUG;
2✔
143
      case TRACE -> IdeLogLevel.TRACE;
2✔
144
      default -> throw new IllegalStateException("" + level);
×
145
    };
146
  }
147

148
  /**
149
   * @param level the JUL {@link Level}.
150
   * @return the {@link IdeLogLevel}.
151
   */
152
  public static IdeLogLevel of(java.util.logging.Level level) {
153

154
    for (IdeLogLevel ideLevel : values()) {
16!
155
      if (ideLevel.julLevel == level) {
4✔
156
        return ideLevel;
2✔
157
      }
158
    }
159
    throw new IllegalStateException("" + level);
×
160
  }
161
}
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