proxy-wasm-rust-sdk
proxy-wasm-rust-sdk copied to clipboard
Consider adding a [$file:$line] prefix to logs
The C++ SDK logs messages in this format:
[$file:$line]::$function $message
Via these macros: https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/blob/921039ae983ce053bf5cba78a85a3c08ff9791e5/proxy_wasm_api.h#L84-L92
The Rust SDK just logs the message: https://github.com/proxy-wasm/proxy-wasm-rust-sdk/blob/9b4b4a576ca28007b46a8f9aaff1ac9baa165cf0/src/logger.rs#L66-L67
File and line are supported in log::Record: https://docs.rs/log/latest/log/struct.Record.html
Function is not supported by Rust: https://stackoverflow.com/a/38088268
The C++ SDK logs messages [...]
I'm sure you'll find many discrepancies between existing SDKs, since they were developed by different people. What's the real goal and motivation behind the suggested change?
Note that the stacktraces already include this information, and application logs can be unique enough that users can identify the source without the file and line number, so I'm not sure how much value would this be adding, to be honest.
But if there is a real use case and/or customer request behind it, then perhaps we should add set_log_metadata(bool)
or something similar (see existing set_log_level
)?