Remove handlebars exception in log implementation

The issue was that the handlebars implementation logs as well and if we
use handlebars in the logger implementation that causes recursion which
crashes the program.

With handlebars 1.0.5, there is a feature[0] to disable logging in
handlebars (compiletime) which we use with this patch. The
exception-checking in the log implementation can be removed therefore.

[0]: https://github.com/sunng87/handlebars-rust/pull/236#issuecomment-427014611

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2018-10-04 16:11:11 +02:00
parent 5d901ae411
commit 1161562372
2 changed files with 5 additions and 13 deletions

View file

@ -28,7 +28,6 @@ ansi_term = "0.11"
is-match = "0.1"
toml-query = "0.7"
error-chain = "0.12"
handlebars = "1.0"
atty = "0.2"
libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" }
@ -46,6 +45,11 @@ version = "0.4"
default-features = false
features = ["std"]
[dependencies.handlebars]
version = "^1.0.5"
default-features = false
features = ["no_logging"]
[features]
default = []

View file

@ -131,18 +131,6 @@ impl Log for ImagLogger {
}
fn log(&self, record: &Record) {
if record.module_path().map(|m| m.starts_with("handlebars")).unwrap_or(false) {
// This is a ugly, yet necessary hack. When logging, we use handlebars for templating.
// But as the handlebars library itselfs logs via a normal logging macro ("debug!()"),
// we have a recursion in our chain.
//
// To prevent this recursion, we return here.
//
// (As of handlebars 0.29.0 - please check whether you can update handlebars if you see
// this. Hopefully the next version has a compiletime flag to disable logging)
return;
}
let mut data = BTreeMap::new();
{