Macro pgx::info

source · []
macro_rules! info {
    ($($arg:tt)*) => { ... };
}
Expand description

Log to Postgres’ info log level.

This macro accepts arguments like the println and format macros. See fmt for information about options.

Given some function:

use pgx::*;

#[pg_extern]
fn sum_array(input: Array<i32>) -> i64 {
    let mut sum = 0 as i64;

    for i in input {
        pgx::info!("i={index:?}, sum={}", sum, index = i);
        sum += i.unwrap_or(-1) as i64;
    }

    sum
}

When run inside PostgreSQL would output:

arrays=# SELECT arrays.sum_array('{1,2,3}');
INFO:  i=Some(1), sum=0
INFO:  i=Some(2), sum=1
INFO:  i=Some(3), sum=3
 sum_array
-----------
         6
(1 row)