The db_postgres, see example below, prints NOTICE messages, is there a way to disable it, so the output would be clean?
The printed message:
NOTICE: relation "users" already exists, skipping
Example that produces it:
import db_postgres
let db = open("localhost", "postgres", "", "nim_test")
let schema = """
create table if not exists users(
id serial not null,
name varchar(100) not null,
primary key (id)
);
"""
db.exec(sql(schema))
db.close()
I tried to register void logger, but it won't help
type VoidLogger* = ref object of Logger
method log*(logger: VoidLogger, level: Level, args: varargs[string, `$`]) = discard
add_handler(VoidLogger())
I tried to register void logger, but it won't help
The message comes from Postgres itself, not from our Nim wrapper.
https://stackoverflow.com/questions/3530767/disable-notices-in-psql-output
Thanks, finally I found how to silence it, if anyone need it:
import db_postgres, postgres
let db = open("localhost", "postgres", "", "nim_test")
let stub_notice_receiver: PQnoticeReceiver = proc (arg: pointer, res: PPGresult){.cdecl.} = discard
discard pqsetNoticeReceiver(db, stub_notice_receiver, nil)
let schema = """
drop table if exists users;
"""
db.exec(sql(schema))
db.close()