proxy-wasm-rust-sdk icon indicating copy to clipboard operation
proxy-wasm-rust-sdk copied to clipboard

Consider adding a [$file:$line] prefix to logs

Open martijneken opened this issue 1 year ago • 1 comments

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

martijneken avatar Feb 09 '24 20:02 martijneken

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)?

PiotrSikora avatar Feb 12 '24 23:02 PiotrSikora