Skip to content

Commit d8ddb02

Browse files
committed
Improve logging
1 parent 4ba1d84 commit d8ddb02

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

src/main/java/software/xdev/saveactions/core/component/Engine.java

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,25 @@ public void processPsiFilesIfNecessary(
7979
}
8080
if(!this.storage.isEnabled(this.activation))
8181
{
82-
LOGGER.info(String.format("Action \"%s\" not enabled on %s", this.activation.getText(), this.project));
82+
LOGGER.info(String.format(
83+
"Action \"%s\" not enabled on %s",
84+
this.activation.getText(),
85+
this.project.getName()));
8386
return;
8487
}
8588

8689
indicator.setIndeterminate(true);
8790
final Set<PsiFile> psiFilesEligible = this.getEligiblePsiFiles(indicator, async);
8891
if(psiFilesEligible.isEmpty())
8992
{
90-
LOGGER.info("No files are eligible");
93+
LOGGER.info("No files are eligible - " + this.project.getName());
9194
return;
9295
}
9396

9497
final List<SaveCommand> processorsEligible = this.getEligibleProcessors(indicator, psiFilesEligible);
9598
if(processorsEligible.isEmpty())
9699
{
97-
LOGGER.info("No processors are eligible");
100+
LOGGER.info("No processors are eligible - " + this.project.getName());
98101
return;
99102
}
100103

@@ -105,7 +108,7 @@ public void processPsiFilesIfNecessary(
105108

106109
private Set<PsiFile> getEligiblePsiFiles(final @NotNull ProgressIndicator indicator, final boolean async)
107110
{
108-
LOGGER.info(String.format("Processing %s files %s mode %s", this.project, this.psiFiles, this.mode));
111+
LOGGER.info(String.format("Processing %s files %s mode %s", this.project.getName(), this.psiFiles, this.mode));
109112
indicator.checkCanceled();
110113
indicator.setText2("Collecting files to process");
111114

@@ -124,7 +127,7 @@ private Set<PsiFile> getEligiblePsiFiles(final @NotNull ProgressIndicator indica
124127
final @NotNull ProgressIndicator indicator,
125128
final Set<PsiFile> psiFilesEligible)
126129
{
127-
LOGGER.info(String.format("Start processors (%d)", this.processors.size()));
130+
LOGGER.info(String.format("Start processors (%d) - %s", this.processors.size(), this.project.getName()));
128131
indicator.checkCanceled();
129132
indicator.setText2("Collecting processors");
130133

@@ -142,7 +145,7 @@ private void flushPsiFiles(
142145
final boolean async,
143146
final Set<PsiFile> psiFilesEligible)
144147
{
145-
LOGGER.info(String.format("Flushing files (%d)", psiFilesEligible.size()));
148+
LOGGER.info(String.format("Flushing files (%d) - %s", psiFilesEligible.size(), this.project.getName()));
146149
indicator.checkCanceled();
147150
indicator.setText2("Flushing files");
148151

@@ -176,7 +179,11 @@ private void execute(
176179
final AtomicInteger executedCount = new AtomicInteger();
177180
final List<SimpleEntry<Action, Result<ResultCode>>> results = saveCommands.stream()
178181
.map(command -> {
179-
LOGGER.info(String.format("Execute command %s on %d files", command, psiFilesEligible.size()));
182+
LOGGER.info(String.format(
183+
"Execute command %s on %d files - %s",
184+
command,
185+
psiFilesEligible.size(),
186+
this.project.getName()));
180187

181188
indicator.checkCanceled();
182189
indicator.setText2("Executing '" + command.getAction().getText() + "'");
@@ -189,9 +196,12 @@ private void execute(
189196
return entry;
190197
})
191198
.toList();
192-
LOGGER.info(String.format("Exit engine with results %s", results.stream()
193-
.map(entry -> entry.getKey() + ":" + entry.getValue())
194-
.toList()));
199+
LOGGER.info(String.format(
200+
"Exit engine with results %s - %s",
201+
results.stream()
202+
.map(entry -> entry.getKey() + ":" + entry.getValue())
203+
.toList(),
204+
this.project.getName()));
195205
}
196206

197207
private boolean isPsiFileEligible(final Project project, final PsiFile psiFile)
@@ -211,7 +221,7 @@ private boolean isProjectValid(final Project project)
211221
final boolean valid = project.isInitialized() && !project.isDisposed();
212222
if(!valid)
213223
{
214-
LOGGER.info("Project invalid. Either not initialized or disposed.");
224+
LOGGER.info(String.format("Project %s invalid. Either not initialized or disposed", project.getName()));
215225
}
216226
return valid;
217227
}
@@ -260,7 +270,7 @@ private boolean isPsiFileFresh(final PsiFile psiFile)
260270
final boolean isFresh = psiFile.getModificationStamp() != 0;
261271
if(!isFresh)
262272
{
263-
LOGGER.info(String.format("File %s is not fresh.", psiFile));
273+
LOGGER.info(String.format("File %s is not fresh", psiFile));
264274
}
265275
return isFresh;
266276
}
@@ -270,7 +280,7 @@ private boolean isPsiFileValid(final PsiFile psiFile)
270280
final boolean valid = psiFile.isValid();
271281
if(!valid)
272282
{
273-
LOGGER.info(String.format("File %s is not valid.", psiFile));
283+
LOGGER.info(String.format("File %s is not valid", psiFile));
274284
}
275285
return valid;
276286
}
@@ -280,7 +290,7 @@ private boolean hasPsiFileText(final PsiFile psiFile)
280290
final boolean valid = psiFile.getTextRange() != null;
281291
if(!valid)
282292
{
283-
LOGGER.info(String.format("File %s has no text.", psiFile));
293+
LOGGER.info(String.format("File %s has no text", psiFile));
284294
}
285295
return valid;
286296
}

src/main/java/software/xdev/saveactions/processors/java/InspectionRunnable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class InspectionRunnable implements Runnable
4040
this.project = project;
4141
this.psiFiles = psiFiles;
4242
this.toolWrapper = new LocalInspectionToolWrapper(inspectionTool);
43-
LOGGER.info(String.format("Running inspection for %s", inspectionTool.getShortName()));
43+
LOGGER.info(String.format("Running inspection for %s - %s", inspectionTool.getShortName(), project.getName()));
4444
}
4545

4646
@Override

0 commit comments

Comments
 (0)