Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
martijneken opened this issue Feb 9, 2024 · 1 comment
Open

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

martijneken opened this issue Feb 9, 2024 · 1 comment

Comments

@martijneken
Copy link
Contributor

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:

let message = record.args().to_string();
hostcalls::log(level, &message).unwrap();

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

@PiotrSikora
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants