public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: master - gfs_controld: new logging stuff
@ 2008-11-19 22:32 David Teigland
0 siblings, 0 replies; only message in thread
From: David Teigland @ 2008-11-19 22:32 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=7bd9b35ac2eba16b0e060800ed709c3d7718e28a
Commit: 7bd9b35ac2eba16b0e060800ed709c3d7718e28a
Parent: 31f870de8f90876fc210b8c4f4702e630495cfc0
Author: David Teigland <teigland@redhat.com>
AuthorDate: Wed Nov 19 16:30:06 2008 -0600
Committer: David Teigland <teigland@redhat.com>
CommitterDate: Wed Nov 19 16:30:06 2008 -0600
gfs_controld: new logging stuff
Changes per recent discussion on cluster-devel mailing list.
Signed-off-by: David Teigland <teigland@redhat.com>
---
group/gfs_controld/Makefile | 4 +-
group/gfs_controld/config.c | 6 +-
group/gfs_controld/config.h | 6 +-
group/gfs_controld/gfs_daemon.h | 27 ++----
group/gfs_controld/logging.c | 184 +++++++--------------------------------
group/gfs_controld/main.c | 16 ++--
6 files changed, 59 insertions(+), 184 deletions(-)
diff --git a/group/gfs_controld/Makefile b/group/gfs_controld/Makefile
index 02da248..7fb8f69 100644
--- a/group/gfs_controld/Makefile
+++ b/group/gfs_controld/Makefile
@@ -21,7 +21,7 @@ OBJS= main.o \
plock.o \
logging.o
-CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${dlmcontrolincdir}
+CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${logtincdir} -I${dlmcontrolincdir}
CFLAGS += -I${corosyncincdir} -I${openaisincdir}
CFLAGS += -I${KERNEL_SRC}/include/
CFLAGS += -I$(S)/../libgfscontrol -I$(S)/../../fence/libfenced/
@@ -30,7 +30,7 @@ CFLAGS += -I${incdir}
LDFLAGS += -L${ccslibdir} -lccs -L${cmanlibdir} -lcman
LDFLAGS += -L${dlmcontrollibdir} -ldlmcontrol
-LDFLAGS += -L${corosynclibdir} -lcpg -llogsys -lpthread
+LDFLAGS += -L${corosynclibdir} -lcpg -llogthread -lpthread
LDFLAGS += -L${openaislibdir} -lSaCkpt
LDFLAGS += -L../../fence/libfenced/ -lfenced
LDFLAGS += -L../lib -lgroup
diff --git a/group/gfs_controld/config.c b/group/gfs_controld/config.c
index 8338255..9ba1f62 100644
--- a/group/gfs_controld/config.c
+++ b/group/gfs_controld/config.c
@@ -25,12 +25,12 @@
#include "config.h"
#include "ccs.h"
-static int ccs_handle;
+int ccs_handle;
/* was a config value set on command line?, 0 or 1. */
int optd_groupd_compat;
-int optd_debug_logsys;
+int optd_debug_logfile;
int optd_enable_withdraw;
int optd_enable_plock;
int optd_plock_debug;
@@ -43,7 +43,7 @@ int optd_drop_resources_age;
/* actual config value from command line, cluster.conf, or default. */
int cfgd_groupd_compat = DEFAULT_GROUPD_COMPAT;
-int cfgd_debug_logsys = DEFAULT_DEBUG_LOGSYS;
+int cfgd_debug_logfile = DEFAULT_DEBUG_LOGFILE;
int cfgd_enable_withdraw = DEFAULT_ENABLE_WITHDRAW;
int cfgd_enable_plock = DEFAULT_ENABLE_PLOCK;
int cfgd_plock_debug = DEFAULT_PLOCK_DEBUG;
diff --git a/group/gfs_controld/config.h b/group/gfs_controld/config.h
index 7ab2ad1..ee0b3b6 100644
--- a/group/gfs_controld/config.h
+++ b/group/gfs_controld/config.h
@@ -2,7 +2,7 @@
#define __CONFIG_DOT_H__
#define DEFAULT_GROUPD_COMPAT 2
-#define DEFAULT_DEBUG_LOGSYS 0
+#define DEFAULT_DEBUG_LOGFILE 0
#define DEFAULT_ENABLE_WITHDRAW 1
#define DEFAULT_ENABLE_PLOCK 1
#define DEFAULT_PLOCK_DEBUG 0
@@ -13,7 +13,7 @@
#define DEFAULT_DROP_RESOURCES_AGE 10000 /* 10 sec */
extern int optd_groupd_compat;
-extern int optd_debug_logsys;
+extern int optd_debug_logfile;
extern int optd_enable_withdraw;
extern int optd_enable_plock;
extern int optd_plock_debug;
@@ -24,7 +24,7 @@ extern int optd_drop_resources_count;
extern int optd_drop_resources_age;
extern int cfgd_groupd_compat;
-extern int cfgd_debug_logsys;
+extern int cfgd_debug_logfile;
extern int cfgd_enable_withdraw;
extern int cfgd_enable_plock;
extern int cfgd_plock_debug;
diff --git a/group/gfs_controld/gfs_daemon.h b/group/gfs_controld/gfs_daemon.h
index 8c4ffb8..1887365 100644
--- a/group/gfs_controld/gfs_daemon.h
+++ b/group/gfs_controld/gfs_daemon.h
@@ -34,7 +34,7 @@
#include <openais/saAis.h>
#include <openais/saCkpt.h>
#include <corosync/cpg.h>
-#include <corosync/engine/logsys.h>
+#include <liblogthread.h>
#include <linux/dlmconstants.h>
#include "libgfscontrol.h"
@@ -89,37 +89,30 @@ extern struct list_head withdrawn_mounts;
void daemon_dump_save(void);
-#define log_debug(fmt, args...) \
+#define log_level(lvl, fmt, args...) \
do { \
- snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL), ##args); \
+ snprintf(daemon_debug_buf, 255, fmt "\n", ##args); \
daemon_dump_save(); \
+ logt_print(lvl, "%s", daemon_debug_buf); \
if (daemon_debug_opt) \
fprintf(stderr, "%s", daemon_debug_buf); \
- if (cfgd_debug_logsys) \
- log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \
} while (0)
+#define log_debug(fmt, args...) log_level(LOG_DEBUG, fmt, ##args)
+#define log_error(fmt, args...) log_level(LOG_ERR, fmt, ##args)
+
#define log_group(g, fmt, args...) \
do { \
- snprintf(daemon_debug_buf, 255, "%ld %s " fmt "\n", time(NULL), \
- (g)->name, ##args); \
+ snprintf(daemon_debug_buf, 255, "%s " fmt "\n", (g)->name, ##args); \
daemon_dump_save(); \
+ logt_print(LOG_DEBUG, "%s", daemon_debug_buf); \
if (daemon_debug_opt) \
fprintf(stderr, "%s", daemon_debug_buf); \
- if (cfgd_debug_logsys) \
- log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \
-} while (0)
-
-#define log_error(fmt, args...) \
-do { \
- log_debug(fmt, ##args); \
- log_printf(LOG_ERR, fmt, ##args); \
} while (0)
#define log_plock(g, fmt, args...) \
do { \
- snprintf(daemon_debug_buf, 255, "%ld %s " fmt "\n", time(NULL), \
- (g)->name, ##args); \
+ snprintf(daemon_debug_buf, 255, "%s " fmt "\n", (g)->name, ##args); \
if (daemon_debug_opt && cfgd_plock_debug) \
fprintf(stderr, "%s", daemon_debug_buf); \
} while (0)
diff --git a/group/gfs_controld/logging.c b/group/gfs_controld/logging.c
index 663d2f8..d6c9e2e 100644
--- a/group/gfs_controld/logging.c
+++ b/group/gfs_controld/logging.c
@@ -1,171 +1,53 @@
#include "gfs_daemon.h"
#include "config.h"
+#include "ccs.h"
-#define DAEMON_NAME "gfs_controld"
-
-/* default: errors go to syslog (/var/log/messages) and <daemon>.log
- logging/debug=on: errors continue going to syslog (/var/log/messages)
- and <daemon>.log, debug messages are added to <daemon>.log. */
-
-#define DEFAULT_MODE LOG_MODE_OUTPUT_SYSLOG_THREADED | \
- LOG_MODE_OUTPUT_FILE | \
- LOG_MODE_NOSUBSYS | \
- LOG_MODE_FILTER_DEBUG_FROM_SYSLOG
-#define DEFAULT_FACILITY SYSLOGFACILITY /* cluster config setting */
-#define DEFAULT_PRIORITY SYSLOGLEVEL /* cluster config setting */
-#define DEFAULT_FILE LOGDIR "/" DAEMON_NAME ".log"
-
-#define DAEMON_LEVEL_PATH "/cluster/logging/logger_subsys[@subsys=\"GFS_CONTROLD\"]/@syslog_level"
-#define DAEMON_DEBUG_PATH "/cluster/logging/logger_subsys[@subsys=\"GFS_CONTROLD\"]/@debug"
-
-/* Read cluster.conf settings and convert them into logsys values.
- If no cluster.conf setting exists, the default that was used in
- logsys_init() is used.
-
- mode from
- "/cluster/logging/@to_stderr"
- "/cluster/logging/@to_syslog"
- "/cluster/logging/@to_file"
+extern int ccs_handle;
- facility from
- "/cluster/logging/@syslog_facility"
-
- priority from
- "/cluster/logging/logger_subsys[@subsys=\"prog_name\"]/@syslog_level"
-
- file from
- "/cluster/logging/@logfile"
-
- debug from
- "/cluster/logging/@debug"
- "/cluster/logging/logger_subsys[@subsys=\"prog_name\"]/@debug"
-*/
+#define DAEMON_NAME "gfs_controld"
+#define DEFAULT_LOG_MODE LOG_MODE_OUTPUT_FILE|LOG_MODE_OUTPUT_SYSLOG
+#define DEFAULT_SYSLOG_FACILITY SYSLOGFACILITY
+#define DEFAULT_SYSLOG_PRIORITY SYSLOGLEVEL
+#define DEFAULT_LOGFILE_PRIORITY LOG_INFO /* ? */
+#define DEFAULT_LOGFILE LOGDIR "/" DAEMON_NAME ".log"
+
+static int log_mode;
+static int syslog_facility;
+static int syslog_priority;
+static int logfile_priority;
+static char logfile[PATH_MAX];
-static int read_ccs_logging(int *mode, int *facility, int *priority, char *file)
+void init_logging(void)
{
- char name[PATH_MAX];
- int val, y, n;
- int m = 0, f = 0, p = 0;
-
- /*
- * mode
- */
-
- m = DEFAULT_MODE;
-
- read_ccs_yesno("/cluster/logging/@to_stderr", &y, &n);
- if (y)
- m |= LOG_MODE_OUTPUT_STDERR;
- if (n)
- m &= ~LOG_MODE_OUTPUT_STDERR;
-
- read_ccs_yesno("/cluster/logging/@to_syslog", &y, &n);
- if (y)
- m |= LOG_MODE_OUTPUT_SYSLOG_THREADED;
- if (n)
- m &= ~LOG_MODE_OUTPUT_SYSLOG_THREADED;
-
- read_ccs_yesno("/cluster/logging/@to_file", &y, &n);
- if (y)
- m |= LOG_MODE_OUTPUT_FILE;
- if (n)
- m &= ~LOG_MODE_OUTPUT_FILE;
-
- *mode = m;
-
- /*
- * facility
- */
-
- f = DEFAULT_FACILITY;
-
- memset(name, 0, sizeof(name));
- read_ccs_name("/cluster/logging/@syslog_facility", name);
-
- if (name[0]) {
- val = logsys_facility_id_get(name);
- if (val >= 0)
- f = val;
- }
+ log_mode = DEFAULT_LOG_MODE;
+ syslog_facility = DEFAULT_SYSLOG_FACILITY;
+ syslog_priority = DEFAULT_SYSLOG_PRIORITY;
+ logfile_priority = DEFAULT_LOGFILE_PRIORITY;
+ strcpy(logfile, DEFAULT_LOGFILE);
- *facility = f;
+ /* logfile_priority is the only one of these options that
+ can be controlled from command line or environment variable */
- /*
- * priority
- */
+ if (cfgd_debug_logfile)
+ logfile_priority = LOG_DEBUG;
- p = DEFAULT_PRIORITY;
-
- memset(name, 0, sizeof(name));
- read_ccs_name(DAEMON_LEVEL_PATH, name);
-
- if (name[0]) {
- val = logsys_priority_id_get(name);
- if (val >= 0)
- p = val;
- }
-
- *priority = p;
-
- /*
- * file
- */
-
- strcpy(file, DEFAULT_FILE);
-
- memset(name, 0, sizeof(name));
- read_ccs_name("/cluster/logging/@logfile", name);
-
- if (name[0])
- strcpy(file, name);
-
- /*
- * debug
- */
-
- if (optd_debug_logsys)
- return 0;
-
- memset(name, 0, sizeof(name));
- read_ccs_name("/cluster/logging/@debug", name);
-
- if (!strcmp(name, "on"))
- cfgd_debug_logsys = 1;
-
- memset(name, 0, sizeof(name));
- read_ccs_name(DAEMON_DEBUG_PATH, name);
-
- if (!strcmp(name, "on"))
- cfgd_debug_logsys = 1;
- else if (!strcmp(name, "off"))
- cfgd_debug_logsys = 0;
-
- return 0;
-}
-
-/* initial settings until we can read cluster.conf logging settings from ccs */
-
-void init_logging(void)
-{
- logsys_init(DAEMON_NAME, DEFAULT_MODE, DEFAULT_FACILITY,
- DEFAULT_PRIORITY, DEFAULT_FILE);
+ logt_init(DAEMON_NAME, log_mode, syslog_facility, syslog_priority,
+ logfile_priority, logfile);
}
-/* this function is also called when we get a cman config-update event */
-
void setup_logging(void)
{
- int mode, facility, priority;
- char file[PATH_MAX];
-
- memset(file, 0, PATH_MAX);
+ ccs_read_logging(ccs_handle, DAEMON_NAME,
+ &cfgd_debug_logfile, &log_mode,
+ &syslog_facility, &syslog_priority,
+ &logfile_priority, logfile);
- read_ccs_logging(&mode, &facility, &priority, file);
- logsys_conf(DAEMON_NAME, mode, facility, priority, file);
+ logt_conf(DAEMON_NAME, log_mode, syslog_facility, syslog_priority,
+ logfile_priority, logfile);
}
void close_logging(void)
{
- logsys_exit();
+ logt_exit();
}
diff --git a/group/gfs_controld/main.c b/group/gfs_controld/main.c
index ccb12ee..cab44f1 100644
--- a/group/gfs_controld/main.c
+++ b/group/gfs_controld/main.c
@@ -1299,8 +1299,8 @@ static void print_usage(void)
printf("\n");
printf("Options:\n");
printf("\n");
- printf(" -D Enable debugging code and don't fork\n");
- printf(" -L <num> Enable (1) or disable (0) debugging to logsys (default %d)\n", DEFAULT_DEBUG_LOGSYS);
+ printf(" -D Enable debugging to stderr and don't fork\n");
+ printf(" -L Enable debugging to log file\n");
printf(" -g <num> groupd compatibility mode, 0 off, 1 on, 2 detect\n");
printf(" 0: use libcpg, no backward compat, best performance\n");
printf(" 1: use libgroup for compat with cluster2/rhel5\n");
@@ -1327,7 +1327,7 @@ static void print_usage(void)
printf(" -V Print program version information, then exit\n");
}
-#define OPTION_STRING "L:DKg:w:f:q:d:p:Pl:o:t:c:a:hV"
+#define OPTION_STRING "LDKg:w:f:q:d:p:Pl:o:t:c:a:hV"
static void read_arguments(int argc, char **argv)
{
@@ -1344,8 +1344,8 @@ static void read_arguments(int argc, char **argv)
break;
case 'L':
- optd_debug_logsys = 1;
- cfgd_debug_logsys = atoi(optarg);
+ optd_debug_logfile = 1;
+ cfgd_debug_logfile = 1;
break;
case 'g':
@@ -1422,9 +1422,9 @@ static void read_arguments(int argc, char **argv)
};
}
- if (!optd_debug_logsys && getenv("GFS_CONTROLD_DEBUG")) {
- optd_debug_logsys = 1;
- cfgd_debug_logsys = atoi(getenv("GFS_CONTROLD_DEBUG"));
+ if (getenv("GFS_CONTROLD_DEBUG")) {
+ optd_debug_logfile = 1;
+ cfgd_debug_logfile = 1;
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-11-19 22:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-19 22:32 cluster: master - gfs_controld: new logging stuff David Teigland
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).