1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
impl Connection {
/**
* Enables tracing of the client/server communication to a debugging file stream.
*
* See [PQtrace](https://www.postgresql.org/docs/current/libpq-control.html#LIBPQ-PQTRACE).
*/
#[cfg(unix)]
pub fn trace(&self, file: std::fs::File) {
use std::os::unix::io::IntoRawFd;
log::trace!("Enable trace");
let c_mode = c"w";
unsafe {
let stream = libc::fdopen(file.into_raw_fd(), c_mode.as_ptr());
pq_sys::PQtrace(self.into(), stream as *mut _);
}
}
/**
* Disables tracing started by `libpq::Connection::trace`.
*
* See [PQuntrace](https://www.postgresql.org/docs/current/libpq-control.html#LIBPQ-PQUNTRACE).
*/
#[cfg(unix)]
pub fn untrace(&self) {
log::trace!("Disable trace");
unsafe {
pq_sys::PQuntrace(self.into());
}
}
/**
* Controls the tracing behavior of client/server communication.
*/
#[cfg(feature = "v14")]
pub fn trace_set_flags(&self, flags: crate::trace::Flags) {
unsafe {
pq_sys::PQsetTraceFlags(self.into(), flags.bits() as i32);
}
}
}