1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-22 02:50:28 +03:00

libctdb: clarify logging levels

Now we have more messages, it seems to make sense to document their usage
and make them consistent.

In particular, LOG_CRIT for internal libctdb problems, LOG_ALERT for
API misuse.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>


(This used to be ctdb commit a6fed3f577c7ec51df38ed15ecb9db6ea2ae7c8f)
This commit is contained in:
Rusty Russell 2010-06-08 16:53:17 +09:30
parent 7aa68b02b2
commit 866cca9637
3 changed files with 30 additions and 17 deletions

View File

@ -46,6 +46,23 @@
* programs; these can be found in the section marked "Synchronous API".
*/
/**
* ctdb_log_fn_t - logging function for ctdbd
* @log_priv: private (typesafe) arg via ctdb_connect
* @severity: syslog-style severity
* @format: printf-style format string.
* @ap: arguments for formatting.
*
* The severity passed to log() are as per syslog(3). In particular,
* LOG_DEBUG is used for tracing, LOG_WARNING is used for unusual
* conditions which don't necessarily return an error through the API,
* LOG_ERR is used for errors such as lost communication with ctdbd or
* out-of-memory, LOG_ALERT is used for library usage bugs, LOG_CRIT is
* used for libctdb internal consistency checks.
*
* The log() function can be typesafe: the @log_priv arg to
* ctdb_donnect and signature of log() should match.
*/
typedef void (*ctdb_log_fn_t)(void *log_priv,
int severity, const char *format, va_list ap);
@ -58,12 +75,8 @@ typedef void (*ctdb_log_fn_t)(void *log_priv,
* Returns a ctdb context if successful or NULL. Use ctdb_free() to
* release the returned ctdb_connection when finished.
*
* The log() function can be typesafe: the log_priv arg and signature
* of log() should match. The priority passed to log() os as per
* syslog(3).
*
* See Also:
* ctdb_log_file()
* ctdb_log_fn_t, ctdb_log_file()
*/
struct ctdb_connection *ctdb_connect(const char *addr,
ctdb_log_fn_t log_fn, void *log_priv);

View File

@ -222,7 +222,7 @@ static struct ctdb_reply_call *unpack_reply_call(struct ctdb_connection *ctdb,
/* Library user error if this isn't a reply to a call. */
if (req->hdr.hdr->operation != CTDB_REQ_CALL) {
errno = EINVAL;
DEBUG(ctdb, LOG_ERR,
DEBUG(ctdb, LOG_ALERT,
"This was not a ctdbd call request: operation %u",
req->hdr.hdr->operation);
return NULL;
@ -230,7 +230,7 @@ static struct ctdb_reply_call *unpack_reply_call(struct ctdb_connection *ctdb,
if (req->hdr.call->callid != callid) {
errno = EINVAL;
DEBUG(ctdb, LOG_ERR,
DEBUG(ctdb, LOG_ALERT,
"This was not a ctdbd %u call request: %u",
callid, req->hdr.call->callid);
return NULL;
@ -259,13 +259,13 @@ struct ctdb_reply_control *unpack_reply_control(struct ctdb_connection *ctdb,
/* Library user error if this isn't a reply to a call. */
if (len < sizeof(*inhdr)) {
errno = EINVAL;
DEBUG(ctdb, LOG_CRIT,
DEBUG(ctdb, LOG_ALERT,
"Short ctdbd control reply: %zu bytes", len);
return NULL;
}
if (req->hdr.hdr->operation != CTDB_REQ_CONTROL) {
errno = EINVAL;
DEBUG(ctdb, LOG_ERR,
DEBUG(ctdb, LOG_ALERT,
"This was not a ctdbd control request: operation %u",
req->hdr.hdr->operation);
return NULL;
@ -274,7 +274,7 @@ struct ctdb_reply_control *unpack_reply_control(struct ctdb_connection *ctdb,
/* ... or if it was a different control from what we expected. */
if (req->hdr.control->opcode != control) {
errno = EINVAL;
DEBUG(ctdb, LOG_ERR,
DEBUG(ctdb, LOG_ALERT,
"This was not an opcode %u ctdbd control request: %u",
control, req->hdr.control->opcode);
return NULL;
@ -335,7 +335,7 @@ bool ctdb_service(struct ctdb_connection *ctdb, int revents)
}
if (holding_lock(ctdb)) {
DEBUG(ctdb, LOG_WARNING, "Do not block while holding lock!");
DEBUG(ctdb, LOG_ALERT, "Do not block while holding lock!");
}
if (revents & POLLOUT) {
@ -646,7 +646,7 @@ static unsigned long lock_magic(struct ctdb_lock *lock)
static void free_lock(struct ctdb_lock *lock)
{
if (lock->held_magic) {
DEBUG(lock->ctdb_db->ctdb, LOG_CRIT,
DEBUG(lock->ctdb_db->ctdb, LOG_ALERT,
"free_lock invalid lock %p", lock);
}
free(lock->hdr);
@ -657,7 +657,7 @@ static void free_lock(struct ctdb_lock *lock)
void ctdb_release_lock(struct ctdb_lock *lock)
{
if (lock->held_magic != lock_magic(lock)) {
DEBUG(lock->ctdb_db->ctdb, LOG_CRIT,
DEBUG(lock->ctdb_db->ctdb, LOG_ALERT,
"ctdb_release_lock invalid lock %p", lock);
} else {
tdb_chainunlock(lock->ctdb_db->tdb, lock->key);
@ -745,7 +745,7 @@ ctdb_readrecordlock_async(struct ctdb_db *ctdb_db, TDB_DATA key,
TDB_DATA data;
if (holding_lock(ctdb_db->ctdb)) {
DEBUG(ctdb_db->ctdb, LOG_ERR,
DEBUG(ctdb_db->ctdb, LOG_ALERT,
"ctdb_readrecordlock_async: already holding lock");
return false;
}
@ -802,14 +802,14 @@ int ctdb_writerecord(struct ctdb_lock *lock, TDB_DATA data)
{
if (lock->held_magic != lock_magic(lock)) {
errno = EBADF;
DEBUG(lock->ctdb_db->ctdb, LOG_ERR,
DEBUG(lock->ctdb_db->ctdb, LOG_ALERT,
"ctdb_writerecord: Can not write. Lock has been released.");
return -1;
}
if (lock->ctdb_db->persistent) {
errno = EINVAL;
DEBUG(lock->ctdb_db->ctdb, LOG_ERR,
DEBUG(lock->ctdb_db->ctdb, LOG_ALERT,
"ctdb_writerecord: cannot write to persistent db");
return -1;
}

View File

@ -54,7 +54,7 @@ bool ctdb_set_message_handler_recv(struct ctdb_connection *ctdb,
return false;
}
if (reply->status != 0) {
DEBUG(ctdb, LOG_WARNING,
DEBUG(ctdb, LOG_ERR,
"ctdb_set_message_handler_recv: status %i",
reply->status);
return false;