Skip to content
Snippets Groups Projects
Commit ff1e612c authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- init

parent b237645f
No related branches found
No related tags found
No related merge requests found
package org.slub.rosetta.dps.repository.plugin;
import java.util.ArrayList;
import java.util.List;
public class SLUBXmlValidationLogger {
private final List<String> log = new ArrayList<>();
private boolean result = true;
private boolean isDebug;
public void error (String err) {
result = false;
log.add("[ERROR] " + err);
}
public void debug (String detail) {
log.add("[DEBUG] " + detail );
}
public void info (String detail) {
log.add("[INFO] " + detail );
}
public void fatal (String detail) {
result = false;
log.add("[FATAL] " + detail );
}
public void warning (String detail) {
log.add("[WARN] " + detail );
}
public void print( ValidationLevel level ) {
for (String e: log) {
switch ( level) {
case debug: if ( e.startsWith("[DEBUG]")) { System.out.println( e); }
case info: if ( e.startsWith("[INFO]")) { System.out.println( e); }
case warn: if ( e.startsWith("[WARN]")) { System.out.println( e); }
case error: if ( e.startsWith("[ERROR]")) { System.out.println( e); }
case fatal: if ( e.startsWith("[FATAL]")) { System.out.println( e); }
}
}
}
public void setResult( boolean r) {
this.result = r;
}
public boolean getResult( ) {
return this.result;
}
public void clear() {
log.clear();
this.result = true;
}
public List<String> getErrors() {
System.out.println("---------------->");
print(ValidationLevel.debug);
System.out.println("<----------------");
return log
.stream()
.filter(f -> f.startsWith("[ERROR]") || f.startsWith("FATAL"))
.toList()
;
}
public String getLog() {
return log
.stream()
.filter(f -> !f.startsWith("[DEBUG]"))
.reduce( "\n", String::concat)
;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment