Skip to content

Commit

Permalink
#2714: loggingOfErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
levBagryansky committed Feb 7, 2024
1 parent 638c611 commit 5ba573f
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.eolang.maven;

import com.jcabi.log.Logger;
import com.jcabi.xml.XML;
import com.yegor256.xsline.TrClasspath;
import com.yegor256.xsline.TrDefault;
import java.nio.file.Path;
Expand Down Expand Up @@ -105,16 +106,38 @@ void exec() {
*/
private Optimization optimization() {
Optimization opt = new OptTrain(
this.loggingOfErrors(),
new TrClasspath<>(
new TrDefault<>(),
"/org/eolang/parser/fail-on-errors.xsl",
"/org/eolang/parser/fail-on-critical.xsl"
).back()
);
if (this.failOnWarning) {
opt = new OptTrain(opt, "/org/eolang/parser/fail-on-warnings.xsl");
opt = new OptTrain(
opt, "/org/eolang/parser/fail-on-warnings.xsl"
);
}
return opt;
}

/**
* Such {@link Optimization} that just logs errors (with any severity) of xmir.
* @return Optimization.
*/
private Optimization loggingOfErrors() {
return xml -> {
for (final XML message: xml.nodes("/program/errors/error")) {
Logger.warn(
this,
"%[file]s, line %s: %s",
xml.xpath("/program/@source").get(0),
message.xpath("@line").get(0),
message.xpath("text()").get(0)
);
}
return xml;
};
}

}

0 comments on commit 5ba573f

Please sign in to comment.