Hi OpenHAB users,
I’m trying to log numbers in my rules into the log file, but it seems to be
not working as expected. Inspired by the documentation ([1]), I’ve created
the following rule:
rule "MyRule1"
when
Item Bedroom_SetTemp received update
then
var Number foo = 1.1
logWarn("Foo", "foo: %1$", foo)
logWarn("Foo", "foo: %1$.1f", foo)
logWarn("Foo", "foo: %1$ bla", 1.1)
logWarn("Foo", "foo: %1$.1f bla", 1.1)
end
When the rule fires up, then I see the following output:
2018-02-09 19:20:27.284 [WARN ] [g.eclipse.smarthome.model.script.Foo] - foo: %1$
2018-02-09 19:20:27.287 [WARN ] [g.eclipse.smarthome.model.script.Foo] - foo: %1$.1f
2018-02-09 19:20:27.290 [WARN ] [g.eclipse.smarthome.model.script.Foo] - foo: %1$ bla
2018-02-09 19:20:27.293 [WARN ] [g.eclipse.smarthome.model.script.Foo] - foo: %1$.1f bla
However, I would expect the following output:
2018-02-09 19:20:27.284 [WARN ] [g.eclipse.smarthome.model.script.Foo] - foo: 1
2018-02-09 19:20:27.287 [WARN ] [g.eclipse.smarthome.model.script.Foo] - foo: 1.1
2018-02-09 19:20:27.290 [WARN ] [g.eclipse.smarthome.model.script.Foo] - foo: 1 bla
2018-02-09 19:20:27.293 [WARN ] [g.eclipse.smarthome.model.script.Foo] - foo: 1.1 bla
I’m running OpenHAB (installed through the provided package repository) on a Pine64 with Fedora 27 (aarch64) with the following java version (part of Fedora):
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
I hope the answer to this will not be a very embarrassing typo or so…
[1] https://docs.openhab.org/administration/logging.html#create-log-entries-in-rules