Rantanen / intercom

Object based cross-language FFI for Rust
MIT License
63 stars 7 forks source link

Add logging support into code generated from macro expansion #135

Closed Rantanen closed 4 years ago

Rantanen commented 4 years ago

Intercom now supports logging through the Rust log infrastructure. This is performed by exposing intercom::logging module and delegating to this module from the macro expansion code.

The call sites are a bit more complicated than usual logging to ensure that the logging does not result in performance penalty in case logging is not enabled. This was verified with micro benchmarking the implementation:

Situation Time
Original 525 ns/iter
Logging enabled ~100 000 ns/iter
Unconditional format_args! 620ns/iter
Conditional format_args! 580ns/iter

There might still be some minor optimization wins here by turning the logging code into usual if .. { log } construct, but I don't want that noise in our quote!(..) calls - a macro exposed by intercom would be an acceptable solution to this, but don't feel like going there for now.

Fixes #134