-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get Postgress function logs (RAISE NOTICE/ RAISE INFO) using nodejs server #4241
Comments
Knex doesn't have any special support for this. Though maybe that client in your pg example is actually connection. You could try to bind those event handlers in https://knexjs.org/#Installation-pooling-afterCreate when knex actually creates new pg connection to its pool. Closing as non-knex issue (and as usage question). If anyone knows better, please feel free to keep on discussion in this thread. |
my pg sample is just for the reference code. Likewise i need to get pg database procedure logs using knex.it might be the knex issue. |
Did you try setting that
Knex doesn't have any special support for that. So if your reference code does it, then knex.raw and that |
Thank you @elhigu I tried with pooling-afterCreate, i got the result. The code is below var pConn = {
host: 'SERVER',
port: 'PORT',
user: 'USER',
password: 'PASSWORD',
database: 'DATABAENAME'
};
var query = "select * from pglog_test()";
try {
const knex = require('knex')({
client: 'pg',
connection: pConn,
pool: {
afterCreate: function (conn, done) {
conn.query('select 1 as result', function (err, result) {
conn.on('notice', function (msg) {
// here we can get the pg procedure logs (raise notice/raise info)
console.log('logs from postgress' + msg);
});
done(err, conn);
});
}
}
});
// procedure calling
knex.raw(query).then(function (result) {
console.log(result);
}).catch(function (error) {
console.log(error);
});
} catch (error) {
console.log(error);
}
|
Environment
Knex version: 0.20.11
Database + version: Pg 11
OS: Ubuntu 16.04 LTS
Question
How to get Postgress function logs ?
i am using knex and pg 11. i had some pg procedures and function,
i need to access the procedure log (RAISE NOTICE & RAISE INFO) using nodejs server.
i tried below code.
This is my sample nodejs code.
my pg procedure is
I need to get the procedure logs (RAISE NOTICE).
how can i get it. the same way i tried with pg npm that was works fine.
by using knex how to get pls suggest me.
working code using pg npm
The text was updated successfully, but these errors were encountered: