~drizzle-trunk/drizzle/development

2244.1.1 by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch.
1
/*
2
 * Drizzle Client & Protocol Library
3
 *
4
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
5
 * All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions are
9
 * met:
10
 *
11
 *     * Redistributions of source code must retain the above copyright
12
 * notice, this list of conditions and the following disclaimer.
13
 *
14
 *     * Redistributions in binary form must reproduce the above
15
 * copyright notice, this list of conditions and the following disclaimer
16
 * in the documentation and/or other materials provided with the
17
 * distribution.
18
 *
19
 *     * The names of its contributors may not be used to endorse or
20
 * promote products derived from this software without specific prior
21
 * written permission.
22
 *
23
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
 *
35
 */
36
2449.1.4 by Brian Aker
Complete update of libdrizzle
37
#pragma once
38
2244.1.1 by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch.
39
/**
40
 * @file
41
 * @brief Local Drizzle Declarations
42
 */
43
44
#ifdef __cplusplus
45
extern "C" {
46
#endif
47
48
/**
49
 * @addtogroup drizzle_local Local Drizzle Declarations
50
 * @ingroup drizzle
51
 * @{
52
 */
53
54
/**
55
 * Set the error string.
56
 *
57
 * @param[in] drizzle Drizzle structure previously initialized with
58
 *  drizzle_create() or drizzle_clone().
59
 * @param[in] function Name of function the error happened in. 
60
 * @param[in] format Format and variable argument list of message.
61
 */
62
DRIZZLE_LOCAL
63
void drizzle_set_error(drizzle_st *drizzle, const char *function,
64
                       const char *format, ...);
65
66
/**
67
 * Log a message.
68
 *
69
 * @param[in] drizzle Drizzle structure previously initialized with
70
 *  drizzle_create() or drizzle_clone().
71
 * @param[in] verbose Logging level of the message.
72
 * @param[in] format Format and variable argument list of message.
73
 * @param[in] args Variable argument list that has been initialized.
74
 */
75
DRIZZLE_LOCAL
76
void drizzle_log(drizzle_st *drizzle, drizzle_verbose_t verbose,
77
                 const char *format, va_list args);
78
79
/**
80
 * Log a fatal message, see drizzle_log() for argument details.
81
 */
82
static inline void drizzle_log_fatal(drizzle_st *drizzle, const char *format,
83
                                     ...)
84
{
85
  va_list args;
86
87
  if (drizzle->verbose >= DRIZZLE_VERBOSE_FATAL)
88
  {
89
    va_start(args, format);
90
    drizzle_log(drizzle, DRIZZLE_VERBOSE_FATAL, format, args);
91
    va_end(args);
92
  }
93
}
94
95
/**
96
 * Log an error message, see drizzle_log() for argument details.
97
 */
98
static inline void drizzle_log_error(drizzle_st *drizzle, const char *format,
99
                                     ...)
100
{
101
  va_list args;
102
103
  if (drizzle->verbose >= DRIZZLE_VERBOSE_ERROR)
104
  {
105
    va_start(args, format);
106
    drizzle_log(drizzle, DRIZZLE_VERBOSE_ERROR, format, args);
107
    va_end(args);
108
  }
109
}
110
111
/**
112
 * Log an info message, see drizzle_log() for argument details.
113
 */
114
static inline void drizzle_log_info(drizzle_st *drizzle, const char *format,
115
                                    ...)
116
{
117
  va_list args;
118
119
  if (drizzle->verbose >= DRIZZLE_VERBOSE_INFO)
120
  {
121
    va_start(args, format);
122
    drizzle_log(drizzle, DRIZZLE_VERBOSE_INFO, format, args);
123
    va_end(args);
124
  }
125
}
126
127
/**
128
 * Log a debug message, see drizzle_log() for argument details.
129
 */
130
static inline void drizzle_log_debug(drizzle_st *drizzle, const char *format,
131
                                     ...)
132
{
133
  va_list args;
134
135
  if (drizzle->verbose >= DRIZZLE_VERBOSE_DEBUG)
136
  {
137
    va_start(args, format);
138
    drizzle_log(drizzle, DRIZZLE_VERBOSE_DEBUG, format, args);
139
    va_end(args);
140
  }
141
}
142
143
/**
144
 * Log a crazy message, see drizzle_log() for argument details.
145
 */
146
static inline void drizzle_log_crazy(drizzle_st *drizzle, const char *format,
147
                                     ...)
148
{
149
  va_list args;
150
151
  if (drizzle->verbose >= DRIZZLE_VERBOSE_CRAZY)
152
  {
153
    va_start(args, format);
154
    drizzle_log(drizzle, DRIZZLE_VERBOSE_CRAZY, format, args);
155
    va_end(args);
156
  }
157
}
158
159
/** @} */
160
161
#ifdef __cplusplus
162
}
163
#endif