A performance-critical plpgsql function in PostgreSQL 9.2 has a "RAISE DEBUG" statement that calls an expensive function for one of the arguments, ie.
RAISE DEBUG 'Details: %', expensive_function(...);
It appears that the function is called even when DEBUG logging is disabled. Is there a way I can check what the current logging level is (both log_min_messages and client_min_messages) in an IF statement or some other way I can call the function only if needed?