I would like to know which is the best way to have log messages from inside C++ / C parts of the code ?
I have seen functions such as pgr_notice() or pgr_error() but I think they are note used in the code for now. Is it the way it should be done? For other ways of logging, it is not clear for me which one is adapted to which context.
For the context, I try to enrich the already existing “contractions” module.
Hi
Not that simple but …
NOTE
All these links are done for this branch at sept 27, 2024. They might be outdated, in the future but they will look to v3.7.0 soon to be released.
This line will add to the class the following class members then it can be used like in this code.
To be able to see the messages when executing a query:
A place to save the log on C++ code
std::ostringstream log;
Get the log
log << pg_graph.get_log();
Create the C string using postgres memopry handling
*log_msg = pgr_msg(log.str().c_str());
And on postgresSQL: (note in this example from the documentation the query does not have error so nothing gets logged except the time it took to read the data)
SET client_min_messages TO DEBUG3;
SET
sampledata=# SELECT * FROM pgr_withPoints(
'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id',
'SELECT pid, edge_id, fraction, side from pointsOfInterest',
-1, 10,
details => true);
DEBUG: Elapsed time for processing pgr_withPoints: 0.000709 sec = (18277.000000 - 17568.000000) / CLOCKS_PER_SEC
Hope this helps
Vicky