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

devonfw / IDEasy / 22317391561

23 Feb 2026 05:30PM UTC coverage: 70.257% (-0.2%) from 70.474%
22317391561

Pull #1714

github

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

4066 of 6384 branches covered (63.69%)

Branch coverage included in aggregate %.

10598 of 14488 relevant lines covered (73.15%)

3.08 hits per line

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

76.74
cli/src/main/java/com/devonfw/tools/ide/context/IdeStartContextImpl.java
1
package com.devonfw.tools.ide.context;
2

3
import java.util.Locale;
4

5
import com.devonfw.tools.ide.log.IdeLogArgFormatter;
6
import com.devonfw.tools.ide.log.IdeLogLevel;
7
import com.devonfw.tools.ide.log.IdeLogListener;
8
import com.devonfw.tools.ide.log.IdeLogListenerBuffer;
9

10
/**
11
 * Implementation of {@link IdeStartContext}.
12
 */
13
public class IdeStartContextImpl implements IdeStartContext {
14

15
  private static IdeStartContextImpl instance;
16

17
  protected final IdeLogListener logListener;
18

19
  protected final IdeLogListenerBuffer logListenerBuffer;
20

21
  private IdeLogLevel logLevelConsole;
22

23
  private IdeLogLevel logLevelLogger;
24

25
  private IdeLogArgFormatter argFormatter;
26

27
  private boolean skipUpdatesMode;
28

29
  private boolean offlineMode;
30

31
  private boolean forceMode;
32

33
  private boolean forcePull;
34

35
  private boolean forcePlugins;
36

37
  private boolean forceRepositories;
38

39
  private boolean batchMode;
40

41
  private boolean quietMode;
42

43
  private boolean privacyMode;
44

45
  private boolean noColorsMode;
46

47
  private boolean writeLogfile;
48

49
  private Locale locale;
50

51
  /**
52
   * @param logLevelConsole the minimum enabled {@link #getLogLevelConsole() log level}.
53
   * @param logListener the {@link #getLogListener() logListener}.
54
   */
55
  public IdeStartContextImpl(IdeLogLevel logLevelConsole, IdeLogListener logListener) {
56

57
    super();
2✔
58
    this.logLevelConsole = logLevelConsole;
3✔
59
    this.logListener = logListener;
3✔
60
    this.argFormatter = IdeLogArgFormatter.DEFAULT;
3✔
61
    IdeStartContextImpl.instance = this;
2✔
62
    if (logListener instanceof IdeLogListenerBuffer buffer) {
6!
63
      this.logListenerBuffer = buffer;
4✔
64
    } else {
65
      this.logListenerBuffer = null;
×
66
    }
67
  }
1✔
68

69
  @Override
70
  public IdeLogListener getLogListener() {
71

72
    return this.logListener;
3✔
73
  }
74

75
  @Override
76
  public IdeLogLevel getLogLevelConsole() {
77

78
    return this.logLevelConsole;
3✔
79
  }
80

81
  /**
82
   * @param logLevelConsole the new {@link IdeLogLevel} for the console.
83
   * @return the previous set logLevel {@link IdeLogLevel}
84
   */
85
  public IdeLogLevel setLogLevelConsole(IdeLogLevel logLevelConsole) {
86

87
    IdeLogLevel previousLogLevel = this.logLevelConsole;
×
88
    if ((previousLogLevel == null) || (previousLogLevel.ordinal() > IdeLogLevel.INFO.ordinal())) {
×
89
      previousLogLevel = IdeLogLevel.INFO;
×
90
    }
91
    this.logLevelConsole = logLevelConsole;
×
92
    return previousLogLevel;
×
93
  }
94

95
  @Override
96
  public IdeLogLevel getLogLevelLogger() {
97

98
    if (this.logLevelLogger == null) {
3!
99
      if ((this.logListenerBuffer != null) && (this.logListenerBuffer.isBuffering())) {
7!
100
        return IdeLogLevel.TRACE;
2✔
101
      }
102
      return this.logLevelConsole;
3✔
103
    }
104
    return this.logLevelLogger;
×
105
  }
106

107
  /**
108
   * @param logLevelLogger the new {@link #getLogLevelLogger() loglevel for the logger}.
109
   */
110
  public void setLogLevelLogger(IdeLogLevel logLevelLogger) {
111

112
    this.logLevelLogger = logLevelLogger;
×
113
  }
×
114

115
  /**
116
   * @return the {@link IdeLogArgFormatter}.
117
   */
118
  public IdeLogArgFormatter getArgFormatter() {
119

120
    return this.argFormatter;
3✔
121
  }
122

123
  /**
124
   * Internal method to set the {@link IdeLogArgFormatter}.
125
   *
126
   * @param argFormatter the new {@link IdeLogArgFormatter}.
127
   */
128
  public void setArgFormatter(IdeLogArgFormatter argFormatter) {
129

130
    this.argFormatter = argFormatter;
3✔
131
  }
1✔
132

133
  /**
134
   * Ensure the logging system is initialized.
135
   */
136
  public void activateLogging() {
137

138
    if (this.logListener instanceof IdeLogListenerBuffer buffer) {
9!
139
      // https://github.com/devonfw/IDEasy/issues/754
140
      buffer.flushAndEndBuffering();
2✔
141
    }
142
  }
1✔
143

144
  /**
145
   * Disables the logging system (temporary).
146
   *
147
   * @param threshold the {@link IdeLogLevel} acting as threshold.
148
   * @see com.devonfw.tools.ide.context.IdeContext#runWithoutLogging(Runnable, IdeLogLevel)
149
   */
150
  public void deactivateLogging(IdeLogLevel threshold) {
151

152
    if (this.logListener instanceof IdeLogListenerBuffer buffer) {
9!
153
      buffer.startBuffering(threshold);
4✔
154
    } else {
155
      throw new IllegalStateException();
×
156
    }
157
  }
1✔
158

159
  @Override
160
  public boolean isQuietMode() {
161

162
    return this.quietMode;
3✔
163
  }
164

165
  /**
166
   * @param quietMode new value of {@link #isQuietMode()}.
167
   */
168
  public void setQuietMode(boolean quietMode) {
169

170
    this.quietMode = quietMode;
3✔
171
  }
1✔
172

173
  @Override
174
  public boolean isBatchMode() {
175

176
    return this.batchMode;
3✔
177
  }
178

179
  /**
180
   * @param batchMode new value of {@link #isBatchMode()}.
181
   */
182
  public void setBatchMode(boolean batchMode) {
183

184
    this.batchMode = batchMode;
3✔
185
  }
1✔
186

187
  @Override
188
  public boolean isForceMode() {
189

190
    return this.forceMode;
3✔
191
  }
192

193
  /**
194
   * @param forceMode new value of {@link #isForceMode()}.
195
   */
196
  public void setForceMode(boolean forceMode) {
197

198
    this.forceMode = forceMode;
3✔
199
  }
1✔
200

201
  @Override
202
  public boolean isPrivacyMode() {
203
    return this.privacyMode;
3✔
204
  }
205

206
  /**
207
   * @param privacyMode new value of {@link #isPrivacyMode()}.
208
   */
209
  public void setPrivacyMode(boolean privacyMode) {
210
    this.privacyMode = privacyMode;
3✔
211
  }
1✔
212

213
  @Override
214
  public boolean isForcePull() {
215

216
    return this.forcePull;
3✔
217
  }
218

219
  /**
220
   * @param forcePull new value of {@link #isForcePull()}.
221
   */
222
  public void setForcePull(boolean forcePull) {
223

224
    this.forcePull = forcePull;
3✔
225
  }
1✔
226

227
  @Override
228
  public boolean isForcePlugins() {
229

230
    return this.forcePlugins;
3✔
231
  }
232

233
  /**
234
   * @param forcePlugins new value of {@link #isForcePlugins()}.
235
   */
236
  public void setForcePlugins(boolean forcePlugins) {
237

238
    this.forcePlugins = forcePlugins;
3✔
239
  }
1✔
240

241
  @Override
242
  public boolean isForceRepositories() {
243

244
    return this.forceRepositories;
3✔
245
  }
246

247
  /**
248
   * @param forceRepositories new value of {@link #isForceRepositories()}.
249
   */
250
  public void setForceRepositories(boolean forceRepositories) {
251

252
    this.forceRepositories = forceRepositories;
3✔
253
  }
1✔
254

255
  @Override
256
  public boolean isOfflineMode() {
257

258
    return this.offlineMode;
3✔
259
  }
260

261
  /**
262
   * @param offlineMode new value of {@link #isOfflineMode()}.
263
   */
264
  public void setOfflineMode(boolean offlineMode) {
265

266
    this.offlineMode = offlineMode;
3✔
267
  }
1✔
268

269
  @Override
270
  public boolean isSkipUpdatesMode() {
271

272
    return this.skipUpdatesMode;
3✔
273
  }
274

275
  /**
276
   * @param skipUpdatesMode new value of {@link #isSkipUpdatesMode()}.
277
   */
278
  public void setSkipUpdatesMode(boolean skipUpdatesMode) {
279

280
    this.skipUpdatesMode = skipUpdatesMode;
3✔
281
  }
1✔
282

283
  @Override
284
  public Locale getLocale() {
285

286
    return this.locale;
3✔
287
  }
288

289
  /**
290
   * @param locale new value of {@link #getLocale()}.
291
   */
292
  public void setLocale(Locale locale) {
293

294
    this.locale = locale;
3✔
295
  }
1✔
296

297
  @Override
298
  public boolean isNoColorsMode() {
299

300
    return this.noColorsMode;
3✔
301
  }
302

303
  /**
304
   * @param noColoursMode new value of {@link #isNoColorsMode()}.
305
   */
306
  public void setNoColorsMode(boolean noColoursMode) {
307

308
    this.noColorsMode = noColoursMode;
3✔
309
  }
1✔
310

311
  /**
312
   * @return {@code true} to write a logfile to disc, {@code false} otherwise.
313
   */
314
  public boolean isWriteLogfile() {
315

316
    return this.writeLogfile;
×
317
  }
318

319
  /**
320
   * @param writeLogfile new value of {@link #isWriteLogfile()}.
321
   */
322
  public void setWriteLogfile(boolean writeLogfile) {
323
    this.writeLogfile = writeLogfile;
3✔
324
  }
1✔
325

326
  /**
327
   * @return the current {@link IdeStartContextImpl} instance.
328
   */
329
  public static IdeStartContextImpl get() {
330

331
    return instance;
2✔
332
  }
333

334
}
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