summaryrefslogtreecommitdiff
path: root/src/utilities/util_verbose.c
blob: cc1667a490cdfcf5a7cccb5c883d1e2cdfcad66f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*-
 * Copyright (c) 2008-2013 WiredTiger, Inc.
 *	All rights reserved.
 *
 * See the file LICENSE for redistribution information.
 */

#include "util.h"

/*
 * __handle_error_verbose --
 *	Verbose WT_EVENT_HANDLER->handle_error implementation: send to stderr.
 */
static int
__handle_error_verbose(WT_EVENT_HANDLER *handler, int error, const char *errmsg)
{
	WT_UNUSED(handler);
	WT_UNUSED(error);

	return (fprintf(stderr, "%s\n", errmsg) < 0 ? EIO : 0);
}

/*
 * __handle_message_verbose --
 *	Verbose WT_EVENT_HANDLER->handle_message implementation: send to stdout.
 */
static int
__handle_message_verbose(WT_EVENT_HANDLER *handler, const char *message)
{
	WT_UNUSED(handler);

	return (printf("%s\n", message) < 0 ? EIO : 0);
}

/*
 * __handle_progress_verbose --
 *	Default WT_EVENT_HANDLER->handle_progress implementation: ignore.
 */
static int
__handle_progress_verbose(
    WT_EVENT_HANDLER *handler, const char *operation, uint64_t progress)
{
	WT_UNUSED(handler);

	return (
	    printf("\r\t%s %-20" PRIu64, operation, progress) < 0 ? EIO : 0);
}

static WT_EVENT_HANDLER __event_handler_verbose = {
	__handle_error_verbose,
	__handle_message_verbose,
	__handle_progress_verbose
};

WT_EVENT_HANDLER *verbose_handler = &__event_handler_verbose;