summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/bench/wtperf/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/bench/wtperf/misc.c')
-rw-r--r--src/third_party/wiredtiger/bench/wtperf/misc.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/third_party/wiredtiger/bench/wtperf/misc.c b/src/third_party/wiredtiger/bench/wtperf/misc.c
index 2821216f240..24b3323a49a 100644
--- a/src/third_party/wiredtiger/bench/wtperf/misc.c
+++ b/src/third_party/wiredtiger/bench/wtperf/misc.c
@@ -30,31 +30,34 @@
/* Setup the logging output mechanism. */
int
-setup_log_file(CONFIG *cfg)
+setup_log_file(WTPERF *wtperf)
{
+ CONFIG_OPTS *opts;
+ size_t len;
int ret;
char *fname;
+ opts = wtperf->opts;
ret = 0;
- if (cfg->verbose < 1)
+ if (opts->verbose < 1)
return (0);
- fname = dcalloc(strlen(cfg->monitor_dir) +
- strlen(cfg->table_name) + strlen(".stat") + 2, 1);
-
- sprintf(fname, "%s/%s.stat", cfg->monitor_dir, cfg->table_name);
- cfg->logf = fopen(fname, "w");
- if (cfg->logf == NULL) {
+ len = strlen(wtperf->monitor_dir) +
+ strlen(opts->table_name) + strlen(".stat") + 2;
+ fname = dmalloc(len);
+ snprintf(fname, len,
+ "%s/%s.stat", wtperf->monitor_dir, opts->table_name);
+ if ((wtperf->logf = fopen(fname, "w")) == NULL) {
ret = errno;
fprintf(stderr, "%s: %s\n", fname, strerror(ret));
}
free(fname);
- if (cfg->logf == NULL)
+ if (wtperf->logf == NULL)
return (ret);
/* Use line buffering for the log file. */
- __wt_stream_set_line_buffer(cfg->logf);
+ __wt_stream_set_line_buffer(wtperf->logf);
return (0);
}
@@ -62,17 +65,20 @@ setup_log_file(CONFIG *cfg)
* Log printf - output a log message.
*/
void
-lprintf(const CONFIG *cfg, int err, uint32_t level, const char *fmt, ...)
+lprintf(const WTPERF *wtperf, int err, uint32_t level, const char *fmt, ...)
{
+ CONFIG_OPTS *opts;
va_list ap;
- if (err == 0 && level <= cfg->verbose) {
+ opts = wtperf->opts;
+
+ if (err == 0 && level <= opts->verbose) {
va_start(ap, fmt);
- vfprintf(cfg->logf, fmt, ap);
+ vfprintf(wtperf->logf, fmt, ap);
va_end(ap);
- fprintf(cfg->logf, "\n");
+ fprintf(wtperf->logf, "\n");
- if (level < cfg->verbose) {
+ if (level < opts->verbose) {
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
@@ -87,11 +93,11 @@ lprintf(const CONFIG *cfg, int err, uint32_t level, const char *fmt, ...)
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, " Error: %s\n", wiredtiger_strerror(err));
- if (cfg->logf != NULL) {
+ if (wtperf->logf != NULL) {
va_start(ap, fmt);
- vfprintf(cfg->logf, fmt, ap);
+ vfprintf(wtperf->logf, fmt, ap);
va_end(ap);
- fprintf(cfg->logf, " Error: %s\n", wiredtiger_strerror(err));
+ fprintf(wtperf->logf, " Error: %s\n", wiredtiger_strerror(err));
}
/* Never attempt to continue if we got a panic from WiredTiger. */