nginxinc / ngx-rust

Rust binding for NGINX
Apache License 2.0
713 stars 59 forks source link

Provide more logging macros #47

Open f5yacobucci opened 10 months ago

f5yacobucci commented 10 months ago

ngx-rust doesn't provide a full set of convenience macros for logging.

We support specific debug logging, but for other logging the user still needs to call the C FFI functions themselves. Needing to provide unnecessary arguments, e.g., in the upstream.rs module example:

ngx_conf_log_error(
            NGX_LOG_EMERG as usize,
            cf,
            0,
            "CUSTOM UPSTREAM no upstream srv_conf".as_bytes().as_ptr() as *const i8,
       );

This can be simplified with a corresponding macro like we do for ngx_log_debug!.

jmccl commented 2 months ago

As an aside 'eprintln!' goes to the error log which is pretty useful, although not what you're proposing.