1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-30 05:23:50 +03:00

implement DbEnv::set_error_stream closes #255

git-svn-id: file:///svn/tokudb@1603 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
Rich Prohaska
2008-01-11 16:14:54 +00:00
parent 3c630d8476
commit d3239fc444
2 changed files with 15 additions and 1 deletions

View File

@@ -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) {

View File

@@ -1,4 +1,5 @@
#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;