Skip to content

Commit

Permalink
Filtering in ComsoleApp
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed May 6, 2024
1 parent 923b3e9 commit d10f038
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/luwrain/app/console/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
public final class App extends AppBase<Strings> implements MonoApp
{
static final ArrayList<Entry> events = new ArrayList<>();
final List<Entry> entries = new ArrayList<>();
private ConsoleCommand[] commands = new ConsoleCommand[0];
private MainLayout mainLayout = null;

Expand All @@ -38,6 +39,9 @@ public App()

@Override protected AreaLayout onAppInit()
{
entries.addAll(events.parallelStream().filter(e->{
return e.logger.startsWith("org.luwrain");
}).toList());
this.mainLayout = new MainLayout(this);
this.commands = new ConsoleCommand[]{
new Commands.Prop(getLuwrain()),
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/luwrain/app/console/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@

final class Entry
{
final String logger;
final String message;
final Throwable ex;
Entry(LogEvent event)
{
this.logger = event.getLoggerName();
this.message = event.getMessage().getFormattedMessage();
this.ex = event.getMessage().getThrowable();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/luwrain/app/console/MainLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class MainLayout extends LayoutBase implements ConsoleArea.InputHandler
this.app = app;
this.consoleArea = new ConsoleArea<Entry>(consoleParams(params -> {
params.name = "LUWRAIN";
params.model = new ListModel<Entry>(App.events);
params.model = new ListModel<Entry>(app.entries);
params.appearance = new Appearance();
params.inputHandler = this;
params.inputPos = ConsoleArea.InputPos.BOTTOM;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/luwrain/script/Hooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static public boolean chainOfResponsibilityNoExc(HookContainer container, String
}
catch(Throwable ex)
{
log.error("The " + hookName + " thrown an exception", ex);
log.error("The " + hookName + " hook thrown an exception", ex);
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/luwrain/script/core/PropertiesObj.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PropertiesObj
{
protected Properties properties;

public PropertiesObj(Properties props)
public PropertiesObj(Properties properties)
{
notNull(properties, "properties");
this.properties = properties;
Expand All @@ -52,7 +52,7 @@ private Object setPropertyImpl(Value[] args)
{
if (args == null || args.length != 2)
throw new IllegalArgumentException("setProperty() takes two argument");
if (args[0] == null || args[0].isNull() || ! args[0].asString().trim().isEmpty())
if (args[0] == null || args[0].isNull() || args[0].asString().trim().isEmpty())
throw new IllegalArgumentException("setProperty() takes a non-empty string as the first argument");
if (args[1] != null && !args[1].isNull() && !args[1].isString())
throw new IllegalArgumentException("setProperty() takes null or a string as the second argument");
Expand Down

0 comments on commit d10f038

Please sign in to comment.