Exception logging broken
When I call this to force a logged exception logException(LOG, IOException("foo"))
, I get this output on the CLI:
20:59:29.737 [main] WARN o.b.m.c.l.LifecycleManagerImpl - java.io.IOException: foo
java.io.IOException: foo
at org.briarproject.mailbox.core.lifecycle.LifecycleManagerImpl.startServices(LifecycleManagerImpl.kt:130)
at org.briarproject.mailbox.cli.Main.run(Main.kt:100)
…
which is OK, but not optimal, as the exception class and message is duplicated.
See the SLF4J FAQs on "Can I log an exception without an accompanying message?"
In short, no.
So bottom line, we should always add a message, I think that's totally OK and reasons why that's a good idea anyway are in that FAQ.
On Android and Logcat however, things look like this:
2022-01-05 20:44:33.162 4318-4433/org.briarproject.mailbox W/o.b.m.c.l.LifecycleManagerImpl: java.io.IOException: foojava.io.IOException: foo
at org.briarproject.mailbox.core.lifecycle.LifecycleManagerImpl.startServices(LifecycleManagerImpl.kt:130)
…
which is ugly. For some reason the exception does not get printed on the next line after the message; it is just appended instead.
Looks like we're using logback-android as the backend on Android and logback-classic as the backend on the CLI and they have different configuration syntax and options.
We should find a configuration that works on both and produces comparable results.