-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
It'd be great if the SQL that pco_store generates had a SQL comment like this prefixed to the query:
/* file:a/b.rs */
SELECT * FROM ...That would make it easier to track down the source of the query from pg_stat_statements, pganalyze, etc.
I haven't tested it but theoretically we can add this with #[track_caller]:
// Mark the function that needs to know its caller's location
#[track_caller]
fn log_call() {
// Get the location of the caller
let location = std::panic::Location::caller();
// Extract the file path (returns &str)
let file_path = location.file();
// You can also get the line and column numbers
let line_number = location.line();
let column_number = location.column();
println!("Called from file: {}, line: {}, column: {}", file_path, line_number, column_number);
}
// Example usage from different locations
fn main() {
log_call();
another_function();
}
fn another_function() {
log_call();
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels