From 0ac7cfc8e417df6494d3071d13faeaee7971ad0d Mon Sep 17 00:00:00 2001 From: Rich Prohaska Date: Mon, 14 Jan 2008 21:30:00 +0000 Subject: [PATCH] add Db::set_errpfx. closes #272 git-svn-id: file:///svn/tokudb@1654 c7de825b-a66e-492c-adef-691d508d4ae1 --- cxx/db.cpp | 4 ++++ cxx/tests/test_error_stream.cpp | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cxx/db.cpp b/cxx/db.cpp index b628fa7aca3..92328c240c6 100644 --- a/cxx/db.cpp +++ b/cxx/db.cpp @@ -167,6 +167,10 @@ int Db::associate(DbTxn *txnid, Db *secondary, int (*callback)(Db *secondary, co return the_Env->maybe_throw_error(ret); } +void Db::set_errpfx(const char *errpfx) { + the_Env->set_errpfx(errpfx); +} + void Db::set_error_stream(std::ostream *new_error_stream) { the_Env->set_error_stream(new_error_stream); } diff --git a/cxx/tests/test_error_stream.cpp b/cxx/tests/test_error_stream.cpp index ad7449b4f9a..96ce08071e6 100644 --- a/cxx/tests/test_error_stream.cpp +++ b/cxx/tests/test_error_stream.cpp @@ -13,13 +13,15 @@ int test_error_stream(const char *dbfile) { r = creat(dbfile, 0777); assert(r >= 0); close(r); DbEnv env(DB_CXX_NO_EXCEPTIONS); - env.set_errpfx("my_test_error_stream"); + env.set_errpfx("my_env_error_stream"); env.set_error_stream(&std::cerr); r = env.open(".", DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0); r = env.open(".", DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == EINVAL); Db db(&env, 0); + db.set_errpfx("my_db_error_stream"); + db.set_error_stream(&std::cerr); r = db.open(0, dbfile, 0, DB_BTREE, DB_CREATE, 0777); assert(r != 0); r = db.close(0); assert(r == 0); r = db.close(0); assert(r == EINVAL);