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

devonfw / IDEasy / 22283847745

22 Feb 2026 07:34PM UTC coverage: 70.75% (+0.3%) from 70.474%
22283847745

Pull #1714

github

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

4064 of 6348 branches covered (64.02%)

Branch coverage included in aggregate %.

10635 of 14428 relevant lines covered (73.71%)

3.1 hits per line

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

79.41
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
  private IdeLogLevel logLevel;
20

21
  private IdeLogArgFormatter argFormatter;
22

23
  private boolean skipUpdatesMode;
24

25
  private boolean offlineMode;
26

27
  private boolean forceMode;
28

29
  private boolean forcePull;
30

31
  private boolean forcePlugins;
32

33
  private boolean forceRepositories;
34

35
  private boolean batchMode;
36

37
  private boolean quietMode;
38

39
  private boolean privacyMode;
40

41
  private boolean noColorsMode;
42

43
  private boolean writeLogfile;
44

45
  private Locale locale;
46

47
  /**
48
   * @param logLevel the minimum enabled {@link #getLogLevel() log level}.
49
   * @param logListener the {@link #getLogListener() logListener}.
50
   */
51
  public IdeStartContextImpl(IdeLogLevel logLevel, IdeLogListener logListener) {
52

53
    super();
2✔
54
    this.logLevel = logLevel;
3✔
55
    this.logListener = logListener;
3✔
56
    this.argFormatter = IdeLogArgFormatter.DEFAULT;
3✔
57
    IdeStartContextImpl.instance = this;
2✔
58
  }
1✔
59

60
  @Override
61
  public IdeLogListener getLogListener() {
62

63
    return this.logListener;
3✔
64
  }
65

66
  @Override
67
  public IdeLogLevel getLogLevel() {
68

69
    return this.logLevel;
3✔
70
  }
71

72
  /**
73
   * Sets the log level.
74
   *
75
   * @param logLevel {@link IdeLogLevel}
76
   * @return the previous set logLevel {@link IdeLogLevel}
77
   */
78
  public IdeLogLevel setLogLevel(IdeLogLevel logLevel) {
79

80
    IdeLogLevel previousLogLevel = this.logLevel;
×
81
    if ((previousLogLevel == null) || (previousLogLevel.ordinal() > IdeLogLevel.INFO.ordinal())) {
×
82
      previousLogLevel = IdeLogLevel.INFO;
×
83
    }
84
    this.logLevel = logLevel;
×
85
    return previousLogLevel;
×
86
  }
87

88
  /**
89
   * @return the {@link IdeLogArgFormatter}.
90
   */
91
  public IdeLogArgFormatter getArgFormatter() {
92

93
    return this.argFormatter;
3✔
94
  }
95

96
  /**
97
   * Internal method to set the {@link IdeLogArgFormatter}.
98
   *
99
   * @param argFormatter the new {@link IdeLogArgFormatter}.
100
   */
101
  public void setArgFormatter(IdeLogArgFormatter argFormatter) {
102

103
    this.argFormatter = argFormatter;
3✔
104
  }
1✔
105

106
  /**
107
   * Ensure the logging system is initialized.
108
   */
109
  public void activateLogging() {
110

111
    if (this.logListener instanceof IdeLogListenerBuffer buffer) {
9✔
112
      // https://github.com/devonfw/IDEasy/issues/754
113
      buffer.flushAndEndBuffering();
2✔
114
    }
115
  }
1✔
116

117
  /**
118
   * Disables the logging system (temporary).
119
   *
120
   * @param threshold the {@link IdeLogLevel} acting as threshold.
121
   * @see com.devonfw.tools.ide.context.IdeContext#runWithoutLogging(Runnable, IdeLogLevel)
122
   */
123
  public void deactivateLogging(IdeLogLevel threshold) {
124

125
    if (this.logListener instanceof IdeLogListenerBuffer buffer) {
9!
126
      buffer.startBuffering(threshold);
4✔
127
    } else {
128
      throw new IllegalStateException();
×
129
    }
130
  }
1✔
131

132
  @Override
133
  public boolean isQuietMode() {
134

135
    return this.quietMode;
3✔
136
  }
137

138
  /**
139
   * @param quietMode new value of {@link #isQuietMode()}.
140
   */
141
  public void setQuietMode(boolean quietMode) {
142

143
    this.quietMode = quietMode;
3✔
144
  }
1✔
145

146
  @Override
147
  public boolean isBatchMode() {
148

149
    return this.batchMode;
3✔
150
  }
151

152
  /**
153
   * @param batchMode new value of {@link #isBatchMode()}.
154
   */
155
  public void setBatchMode(boolean batchMode) {
156

157
    this.batchMode = batchMode;
3✔
158
  }
1✔
159

160
  @Override
161
  public boolean isForceMode() {
162

163
    return this.forceMode;
3✔
164
  }
165

166
  /**
167
   * @param forceMode new value of {@link #isForceMode()}.
168
   */
169
  public void setForceMode(boolean forceMode) {
170

171
    this.forceMode = forceMode;
3✔
172
  }
1✔
173

174
  @Override
175
  public boolean isPrivacyMode() {
176
    return this.privacyMode;
3✔
177
  }
178

179
  /**
180
   * @param privacyMode new value of {@link #isPrivacyMode()}.
181
   */
182
  public void setPrivacyMode(boolean privacyMode) {
183
    this.privacyMode = privacyMode;
3✔
184
  }
1✔
185

186
  @Override
187
  public boolean isForcePull() {
188

189
    return this.forcePull;
3✔
190
  }
191

192
  /**
193
   * @param forcePull new value of {@link #isForcePull()}.
194
   */
195
  public void setForcePull(boolean forcePull) {
196

197
    this.forcePull = forcePull;
3✔
198
  }
1✔
199

200
  @Override
201
  public boolean isForcePlugins() {
202

203
    return this.forcePlugins;
3✔
204
  }
205

206
  /**
207
   * @param forcePlugins new value of {@link #isForcePlugins()}.
208
   */
209
  public void setForcePlugins(boolean forcePlugins) {
210

211
    this.forcePlugins = forcePlugins;
3✔
212
  }
1✔
213

214
  @Override
215
  public boolean isForceRepositories() {
216

217
    return this.forceRepositories;
3✔
218
  }
219

220
  /**
221
   * @param forceRepositories new value of {@link #isForceRepositories()}.
222
   */
223
  public void setForceRepositories(boolean forceRepositories) {
224

225
    this.forceRepositories = forceRepositories;
3✔
226
  }
1✔
227

228
  @Override
229
  public boolean isOfflineMode() {
230

231
    return this.offlineMode;
3✔
232
  }
233

234
  /**
235
   * @param offlineMode new value of {@link #isOfflineMode()}.
236
   */
237
  public void setOfflineMode(boolean offlineMode) {
238

239
    this.offlineMode = offlineMode;
3✔
240
  }
1✔
241

242
  @Override
243
  public boolean isSkipUpdatesMode() {
244

245
    return this.skipUpdatesMode;
3✔
246
  }
247

248
  /**
249
   * @param skipUpdatesMode new value of {@link #isSkipUpdatesMode()}.
250
   */
251
  public void setSkipUpdatesMode(boolean skipUpdatesMode) {
252

253
    this.skipUpdatesMode = skipUpdatesMode;
3✔
254
  }
1✔
255

256
  @Override
257
  public Locale getLocale() {
258

259
    return this.locale;
3✔
260
  }
261

262
  /**
263
   * @param locale new value of {@link #getLocale()}.
264
   */
265
  public void setLocale(Locale locale) {
266

267
    this.locale = locale;
3✔
268
  }
1✔
269

270
  @Override
271
  public boolean isNoColorsMode() {
272

273
    return this.noColorsMode;
3✔
274
  }
275

276
  /**
277
   * @param noColoursMode new value of {@link #isNoColorsMode()}.
278
   */
279
  public void setNoColorsMode(boolean noColoursMode) {
280

281
    this.noColorsMode = noColoursMode;
3✔
282
  }
1✔
283

284
  /**
285
   * @return {@code true} to write a logfile to disc, {@code false} otherwise.
286
   */
287
  public boolean isWriteLogfile() {
288

289
    return this.writeLogfile;
×
290
  }
291

292
  /**
293
   * @param writeLogfile new value of {@link #isWriteLogfile()}.
294
   */
295
  public void setWriteLogfile(boolean writeLogfile) {
296
    this.writeLogfile = writeLogfile;
×
297
  }
×
298

299
  /**
300
   * @return the current {@link IdeStartContextImpl} instance.
301
   */
302
  public static IdeStartContextImpl get() {
303

304
    return instance;
2✔
305
  }
306

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