Announcing slog_unwraps, syntactic sugar to unwrap while logging the error

#1

Just published my very first crate on crates! slog_unwraps allows you to call .unwraps( log ) on a result in order to avoid matching and manually use a logging macro before unwrapping. It will also report the file and line number of the caller, so you don’t have to turn on backtraces.

It’s a development convenience crate, which will not do you much good in production.

I am thinking of a means of logging any panic with slog, but I haven’t figured the correct way to do this yet, as there can only be one panic hook for an application if I’m not mistaking… but that’s for another crate anyways.

let f       = File::open( "dont.exist" );
let _file = f.unwraps( &log );

gives:

Mar 08 18:13:52.034 CRIT PANIC - fn `main` calls `unwraps` @ examples/basic.rs:20 -> Error: No such file or directory (os error 2)
0 Likes