Skip to content

Commit

Permalink
Try to fix jinja templates
Browse files Browse the repository at this point in the history
  • Loading branch information
shueja committed Jan 12, 2024
1 parent 6064048 commit 9105349
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
9 changes: 6 additions & 3 deletions monologue/src/generate/java/DataLogger.java.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ class DataLogger extends GenericLogger {
level,
consumer
);
{%else%}
{%if t.java.IsArray == true%}
{%elif t.java.IsArray == true%}
if (this.isLazy()) {
consumer = new LongConsumer() {
private {{t.java.ValueType}} lastValue = new {{t.java.ValueType}} {};
Expand All @@ -104,6 +103,11 @@ class DataLogger extends GenericLogger {
}
};
}
addField(
entryName,
level,
consumer
);
{%else%}
if (this.isLazy()) {
consumer = new LongConsumer() {
Expand All @@ -127,7 +131,6 @@ class DataLogger extends GenericLogger {
entry.append(value, timestamp);
};
}
{%endif%}

addField(
entryName,
Expand Down
16 changes: 13 additions & 3 deletions monologue/src/generate/java/NTLogger.java.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ class NTLogger extends GenericLogger {
},
entry::unpublish
);
{%else%}
{%if t.java.IsArray == true%}
{%elif t.java.IsArray == true%}
if (this.isLazy()) {
consumer = new LongConsumer() {
private {{t.java.ValueType}} lastValue = new {{t.java.ValueType}} {};
Expand All @@ -150,6 +149,18 @@ class NTLogger extends GenericLogger {
}
};
}

addField(
entryName,
level,
consumer,
() -> {
var value = valueSupplier.get();
if (value == null) { return;}
entry.set(value);
},
entry::unpublish
);
{%else%}
if (this.isLazy()) {
consumer = new LongConsumer() {
Expand All @@ -172,7 +183,6 @@ class NTLogger extends GenericLogger {
entry.set(value, timestamp);
};
}
{%endif%}

addField(
entryName,
Expand Down

0 comments on commit 9105349

Please sign in to comment.