00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "db_config.h"
00011
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014
00015 #include <stdlib.h>
00016 #include <string.h>
00017 #endif
00018
00019 #include "db_int.h"
00020 #include "dbinc/db_page.h"
00021 #include "dbinc/db_am.h"
00022 #include "dbinc/log.h"
00023
00024 static int __log_printf_int __P((DB_ENV *, DB_TXN *, const char *, va_list));
00025
00026
00027
00028
00029
00030
00031
00032
00033 int
00034 #ifdef STDC_HEADERS
00035 __log_printf_capi(DB_ENV *dbenv, DB_TXN *txnid, const char *fmt, ...)
00036 #else
00037 __log_printf_capi(dbenv, txnid, fmt, va_alist)
00038 DB_ENV *dbenv;
00039 DB_TXN *txnid;
00040 const char *fmt;
00041 va_dcl
00042 #endif
00043 {
00044 va_list ap;
00045 int ret;
00046
00047 #ifdef STDC_HEADERS
00048 va_start(ap, fmt);
00049 #else
00050 va_start(ap);
00051 #endif
00052 ret = __log_printf_pp(dbenv, txnid, fmt, ap);
00053 va_end(ap);
00054
00055 return (ret);
00056 }
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 int
00070 __log_printf_pp(dbenv, txnid, fmt, ap)
00071 DB_ENV *dbenv;
00072 DB_TXN *txnid;
00073 const char *fmt;
00074 va_list ap;
00075 {
00076 DB_THREAD_INFO *ip;
00077 int rep_check, ret, t_ret;
00078
00079 PANIC_CHECK(dbenv);
00080 ENV_REQUIRES_CONFIG(dbenv,
00081 dbenv->lg_handle, "DB_ENV->log_printf", DB_INIT_LOG);
00082
00083 ENV_ENTER(dbenv, ip);
00084 rep_check = IS_ENV_REPLICATED(dbenv) ? 1 : 0;
00085 if (rep_check && (ret = __env_rep_enter(dbenv, 0)) != 0)
00086 return (ret);
00087
00088 ret = __log_printf_int(dbenv, txnid, fmt, ap);
00089
00090 if (rep_check && (t_ret = __env_db_rep_exit(dbenv)) != 0 && (ret) == 0)
00091 ret = t_ret;
00092 va_end(ap);
00093 ENV_LEAVE(dbenv, ip);
00094
00095 return (ret);
00096 }
00097
00098
00099
00100
00101
00102
00103
00104
00105 int
00106 #ifdef STDC_HEADERS
00107 __log_printf(DB_ENV *dbenv, DB_TXN *txnid, const char *fmt, ...)
00108 #else
00109 __log_printf(dbenv, txnid, fmt, va_alist)
00110 DB_ENV *dbenv;
00111 DB_TXN *txnid;
00112 const char *fmt;
00113 va_dcl
00114 #endif
00115 {
00116 va_list ap;
00117 int ret;
00118
00119 #ifdef STDC_HEADERS
00120 va_start(ap, fmt);
00121 #else
00122 va_start(ap);
00123 #endif
00124 ret = __log_printf_int(dbenv, txnid, fmt, ap);
00125 va_end(ap);
00126
00127 return (ret);
00128 }
00129
00130
00131
00132
00133
00134 static int
00135 __log_printf_int(dbenv, txnid, fmt, ap)
00136 DB_ENV *dbenv;
00137 DB_TXN *txnid;
00138 const char *fmt;
00139 va_list ap;
00140 {
00141 DBT opdbt, msgdbt;
00142 DB_LSN lsn;
00143 char __logbuf[2048];
00144
00145 if (!DBENV_LOGGING(dbenv)) {
00146 __db_err(dbenv, "Logging not currently permitted");
00147 return (EAGAIN);
00148 }
00149
00150 memset(&opdbt, 0, sizeof(opdbt));
00151 opdbt.data = "DIAGNOSTIC";
00152 opdbt.size = sizeof("DIAGNOSTIC") - 1;
00153
00154 memset(&msgdbt, 0, sizeof(msgdbt));
00155 msgdbt.data = __logbuf;
00156 msgdbt.size = (u_int32_t)vsnprintf(__logbuf, sizeof(__logbuf), fmt, ap);
00157
00158 return (__db_debug_log(
00159 dbenv, txnid, &lsn, 0, &opdbt, -1, &msgdbt, NULL, 0));
00160 }