1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

ctdb-common: Keep debug level related functions with logging code

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Amitay Isaacs 2014-06-06 15:00:08 +10:00 committed by Martin Schwenke
parent d09f8134c1
commit e114830124
2 changed files with 40 additions and 40 deletions

View File

@ -23,6 +23,9 @@
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
#include "../include/ctdb_client.h" #include "../include/ctdb_client.h"
int LogLevel = DEBUG_NOTICE;
int this_log_level = 0;
int log_ringbuf_size; int log_ringbuf_size;
#define MAX_LOG_SIZE 128 #define MAX_LOG_SIZE 128
@ -198,3 +201,40 @@ int32_t ctdb_control_clear_log(struct ctdb_context *ctdb)
return 0; return 0;
} }
struct debug_levels debug_levels[] = {
{DEBUG_EMERG, "EMERG"},
{DEBUG_ALERT, "ALERT"},
{DEBUG_CRIT, "CRIT"},
{DEBUG_ERR, "ERR"},
{DEBUG_WARNING, "WARNING"},
{DEBUG_NOTICE, "NOTICE"},
{DEBUG_INFO, "INFO"},
{DEBUG_DEBUG, "DEBUG"},
{0, NULL}
};
const char *get_debug_by_level(int32_t level)
{
int i;
for (i=0; debug_levels[i].description != NULL; i++) {
if (debug_levels[i].level == level) {
return debug_levels[i].description;
}
}
return "Unknown";
}
int32_t get_debug_by_desc(const char *desc)
{
int i;
for (i=0; debug_levels[i].description != NULL; i++) {
if (!strcasecmp(debug_levels[i].description, desc)) {
return debug_levels[i].level;
}
}
return DEBUG_ERR;
}

View File

@ -25,9 +25,6 @@
#include "system/shmem.h" #include "system/shmem.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
int LogLevel = DEBUG_NOTICE;
int this_log_level = 0;
/* /*
return error string for last error return error string for last error
*/ */
@ -407,43 +404,6 @@ unsigned ctdb_addr_to_port(ctdb_sock_addr *addr)
return 0; return 0;
} }
struct debug_levels debug_levels[] = {
{DEBUG_EMERG, "EMERG"},
{DEBUG_ALERT, "ALERT"},
{DEBUG_CRIT, "CRIT"},
{DEBUG_ERR, "ERR"},
{DEBUG_WARNING, "WARNING"},
{DEBUG_NOTICE, "NOTICE"},
{DEBUG_INFO, "INFO"},
{DEBUG_DEBUG, "DEBUG"},
{0, NULL}
};
const char *get_debug_by_level(int32_t level)
{
int i;
for (i=0; debug_levels[i].description != NULL; i++) {
if (debug_levels[i].level == level) {
return debug_levels[i].description;
}
}
return "Unknown";
}
int32_t get_debug_by_desc(const char *desc)
{
int i;
for (i=0; debug_levels[i].description != NULL; i++) {
if (!strcasecmp(debug_levels[i].description, desc)) {
return debug_levels[i].level;
}
}
return DEBUG_ERR;
}
/* we don't lock future pages here; it would increase the chance that /* we don't lock future pages here; it would increase the chance that
* we'd fail to mmap later on. */ * we'd fail to mmap later on. */
void ctdb_lockdown_memory(struct ctdb_context *ctdb) void ctdb_lockdown_memory(struct ctdb_context *ctdb)