Commit d3239fc4 authored by Rich Prohaska's avatar Rich Prohaska

implement DbEnv::set_error_stream closes #255

git-svn-id: file:///svn/tokudb@1603 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3c630d84
......@@ -12,7 +12,7 @@ DbEnv::DbEnv (u_int32_t flags)
}
DbEnv::DbEnv(DB_ENV *env, u_int32_t flags)
: do_no_exceptions((flags&DB_CXX_NO_EXCEPTIONS)!=0)
: do_no_exceptions((flags&DB_CXX_NO_EXCEPTIONS)!=0), _error_stream(0)
{
the_env = env;
if (env == 0) {
......@@ -126,6 +126,17 @@ void DbEnv::set_errcall(void (*db_errcall_fcn)(const DbEnv *, const char *, cons
the_env->set_errcall(the_env, toku_db_env_errcall_c);
}
extern "C" void toku_db_env_error_stream_c(const DB_ENV *dbenv_c, const char *errpfx, const char *msg) {
DbEnv *dbenv = (DbEnv *) dbenv_c->api1_internal;
if (dbenv->_error_stream)
*dbenv->_error_stream << errpfx << ":" << msg << "\n";
}
void DbEnv::set_error_stream(std::ostream *new_error_stream) {
_error_stream = new_error_stream;
the_env->set_errcall(the_env, toku_db_env_error_stream_c);
}
// locking not yet implemented
int DbEnv::set_lk_max_locks(u_int32_t max_locks) {
......
#include <db.h>
#include <iostream>
#include <exception>
#include <string.h>
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
......@@ -161,6 +162,7 @@ class DbEnv {
void err(int error, const char *fmt, ...);
void set_errfile(FILE *errfile);
void set_errcall(void (*)(const DbEnv *, const char *, const char *));
void set_error_stream(std::ostream *);
int get_flags(u_int32_t *flagsp);
// locking
......@@ -178,6 +180,7 @@ class DbEnv {
// somewhat_private:
int do_no_exceptions; // This should be private!!!
void (*errcall)(const DbEnv *, const char *, const char *);
std::ostream *_error_stream;
private:
DB_ENV *the_env;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment