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

devonfw / IDEasy / 22241505980

20 Feb 2026 09:16PM UTC coverage: 70.656% (+0.2%) from 70.474%
22241505980

Pull #1710

github

web-flow
Merge 04e4bdacd into 379acdc9d
Pull Request #1710: #404: allow logging via SLF4J

4121 of 6440 branches covered (63.99%)

Branch coverage included in aggregate %.

10704 of 14542 relevant lines covered (73.61%)

3.13 hits per line

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

73.97
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
import com.devonfw.tools.ide.context.IdeContext;
8

9
/**
10
 * {@link Enum} with the available log-levels.
11
 *
12
 * @see IdeContext#level(IdeLogLevel)
13
 */
14
public enum IdeLogLevel {
3✔
15

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

19
  /** {@link IdeLogLevel} for debugging (more detailed logging). */
20
  DEBUG("\033[90m", Level.DEBUG, null, java.util.logging.Level.FINE),
10✔
21

22
  /** {@link IdeLogLevel} for general information (regular logging). */
23
  INFO(null, Level.INFO, null, java.util.logging.Level.INFO),
10✔
24

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

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

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

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

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

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

47
  private final String color;
48

49
  private final Level slf4jLevel;
50

51
  private final Marker slf4jMarker;
52

53
  private final java.util.logging.Level julLevel;
54

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

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

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

71
    return this.color;
3✔
72
  }
73

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

79
    return "\033[0m"; // reset color
2✔
80
  }
81

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

87
    return this.slf4jLevel;
3✔
88
  }
89

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

95
    return this.slf4jMarker;
3✔
96
  }
97

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

103
    return this.julLevel;
3✔
104
  }
105

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

111
    return (this == STEP) || (this == INTERACTION) || (this == SUCCESS) || (this == PROCESSABLE);
14!
112
  }
113

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

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

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

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

150
  /**
151
   * @param level the SLF4J log {@link Level}.
152
   * @param marker the SLF4J {@link Marker}.
153
   * @return the {@link IdeLogLevel}.
154
   */
155
  public static java.util.logging.Level convertLevelFromSlf4jToJul(Level level, Marker marker) {
156

157
    return switch (level) {
×
158
      case ERROR -> java.util.logging.Level.SEVERE;
×
159
      case WARN -> java.util.logging.Level.WARNING;
×
160
      case INFO -> java.util.logging.Level.INFO;
×
161
      case DEBUG -> java.util.logging.Level.FINE;
×
162
      case TRACE -> java.util.logging.Level.FINER;
×
163
      default -> throw new IllegalStateException("" + level);
×
164
    };
165
  }
166
}
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