mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-08-06 15:25:32 +00:00
The logsys logging system. Read logsys_overview.8.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1428 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
parent
4336be7c4c
commit
113a3c4f88
@ -1,5 +1,6 @@
|
||||
# Copyright (c) 2002-2006 MontaVista Software, Inc.
|
||||
# Copyright (c) 2006 Sun Microsystems, Inc.
|
||||
# Copyright (c) 2006-2007 Red Hat, Inc.
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
@ -34,7 +35,6 @@
|
||||
include ../Makefile.inc
|
||||
|
||||
override CFLAGS += -I../include
|
||||
LDFLAGS += -L./
|
||||
|
||||
ifeq (${BUILD_DYNAMIC}, 1)
|
||||
override LDFLAGS += ${DYFLAGS}
|
||||
@ -51,7 +51,10 @@ endif
|
||||
# Totem objects
|
||||
TOTEM_SRC = aispoll.c totemip.c totemnet.c totemrrp.c totemsrp.c totemmrp.c totempg.c crypto.c wthread.c
|
||||
TOTEM_OBJS = aispoll.o totemip.o totemnet.o totemrrp.o totemsrp.o totemmrp.o totempg.o crypto.o wthread.o
|
||||
EXEC_LIBS = libtotem_pg.a
|
||||
LOGSYS_SRC = wthread.c logsys.c
|
||||
LOGSYS_OBJS = wthread.o logsys.o
|
||||
|
||||
EXEC_LIBS = libtotem_pg.a liblogsys.a
|
||||
|
||||
# AMF objects
|
||||
AMF_SRC = amf.c amfutil.c amfnode.c amfcluster.c amfapp.c amfsg.c amfsu.c amfcomp.c amfsi.c
|
||||
@ -62,25 +65,25 @@ LCR_SRC = evs.c clm.c ckpt.c evt.c lck.c msg.c cfg.c cpg.c aisparser.c vsf_ykd.c
|
||||
LCR_OBJS = evs.o clm.o ckpt.o evt.o lck.o msg.o cfg.o cpg.o aisparser.o vsf_ykd.o $(AMF_OBJS)
|
||||
|
||||
# main executive objects
|
||||
MAIN_SRC = main.c print.c mempool.c util.c sync.c service.c ipc.c flow.c timer.c \
|
||||
MAIN_SRC = main.c mempool.c util.c sync.c service.c ipc.c flow.c timer.c \
|
||||
totemconfig.c mainconfig.c
|
||||
MAIN_OBJS = main.o print.o mempool.o util.o sync.o service.o ipc.o flow.o timer.o \
|
||||
MAIN_OBJS = main.o mempool.o util.o sync.o service.o ipc.o flow.o timer.o \
|
||||
totemconfig.o mainconfig.o ../lcr/lcr_ifact.o
|
||||
OTHER_OBJS = objdb.o
|
||||
|
||||
ifeq (${BUILD_DYNAMIC}, 1)
|
||||
EXEC_OBJS = $(TOTEM_OBJS) $(MAIN_OBJS)
|
||||
#EXEC_OBJS = $(TOTEM_OBJS) $(LOGSYS_OBJS) $(MAIN_OBJS)
|
||||
EXEC_OBJS = $(MAIN_OBJS)
|
||||
override CFLAGS += -fPIC
|
||||
|
||||
all:libtotem_pg.a libtotem_pg.so.2.0.0 ../lcr/lcr_ifact.o \
|
||||
aisexec \
|
||||
all:libtotem_pg.a libtotem_pg.so.2.0.0 liblogsys.a liblogsys.so.2.0.0 \
|
||||
../lcr/lcr_ifact.o aisexec \
|
||||
service_evs.lcrso service_clm.lcrso service_amf.lcrso \
|
||||
service_ckpt.lcrso service_evt.lcrso service_lck.lcrso \
|
||||
service_msg.lcrso service_cfg.lcrso service_cpg.lcrso \
|
||||
objdb.lcrso aisparser.lcrso vsf_ykd.lcrso keygen openais-instantiate
|
||||
else
|
||||
EXEC_OBJS = $(TOTEM_OBJS) $(MAIN_OBJS) $(OTHER_OBJS) $(LCR_OBJS)
|
||||
all: libtotem_pg.a aisexec keygen openais-instantiate
|
||||
EXEC_OBJS = $(MAIN_OBJS) $(LCR_OBJS)
|
||||
all: libtotem_pg.a liblogsys.a aisexec keygen openais-instantiate
|
||||
endif
|
||||
|
||||
|
||||
@ -163,22 +166,30 @@ objdb.lcrso: objdb.o
|
||||
|
||||
endif
|
||||
|
||||
aisexec: $(EXEC_OBJS) libtotem_pg.a
|
||||
aisexec: $(EXEC_OBJS) $(EXEC_LIBS)
|
||||
$(CC) $(LDFLAGS) $(EXEC_OBJS) $(EXEC_LIBS) -o aisexec
|
||||
|
||||
libtotem_pg.a: $(TOTEM_OBJS)
|
||||
$(AR) -rc libtotem_pg.a $(TOTEM_OBJS)
|
||||
|
||||
liblogsys.a: $(LOGSYS_OBJS)
|
||||
$(AR) -rc liblogsys.a $(LOGSYS_OBJS)
|
||||
|
||||
ifeq (${OPENAIS_COMPAT}, DARWIN)
|
||||
|
||||
libtotem_pg.so.2.0.0: $(TOTEM_OBJS)
|
||||
$(CC) $(LDFLAGS) -bundle -bind_at_load $(TOTEM_OBJS) -o $@
|
||||
|
||||
liblogsys.so.2.0.0: $(LOGSYS_OBJS)
|
||||
$(CC) $(LDFLAGS) -bundle -bind_at_load $(LOGSYS_OBJS) -o $@
|
||||
else
|
||||
|
||||
libtotem_pg.so.2.0.0: $(TOTEM_OBJS)
|
||||
$(CC) $(LDFLAGS) -shared -Wl,-soname,libtotem_pg.so.2 $(TOTEM_OBJS) -o $@
|
||||
|
||||
liblogsys.so.2.0.0: $(LIBLOGSYS_OBJS)
|
||||
$(CC) $(LDFLAGS) -shared -Wl,-soname,liblogsys.so.2 $(LOGSYS_OBJS) -o $@
|
||||
|
||||
endif
|
||||
|
||||
keygen: keygen.o
|
||||
@ -191,7 +202,7 @@ clean:
|
||||
rm -f aisexec $(OBJS) *.o *.lcrso libtotem_pg.so* libtotem_pg.a gmon.out keygen keygen.o openais-instantiate *.da *.bb *.bbg
|
||||
|
||||
depend:
|
||||
makedepend -Y -- $(CFLAGS) $(CPPFLAGS) $(EXEC_SRC) $(TOTEM_SRC) $(LCR_SRC) > /dev/null 2>&1
|
||||
makedepend -Y -- $(CFLAGS) $(CPPFLAGS) $(EXEC_SRC) $(TOTEM_SRC) $(LOGSYS_SRC) $(LCR_SRC) > /dev/null 2>&1
|
||||
|
||||
# - fPIC rules required for service handler shared objects
|
||||
../lcr/lcr_ifact.o: ../lcr/lcr_ifact.c
|
||||
@ -288,89 +299,89 @@ evs.o: ../exec/totemip.h ../include/ipc_evs.h ../include/saAis.h
|
||||
evs.o: ../include/evs.h ../include/ipc_gen.h ../include/list.h
|
||||
evs.o: ../include/queue.h ../lcr/lcr_comp.h aispoll.h totempg.h totemsrp.h
|
||||
evs.o: main.h ../include/saClm.h mainconfig.h objdb.h mempool.h service.h
|
||||
evs.o: print.h
|
||||
evs.o: logsys.h
|
||||
clm.o: totem.h totemip.h ../include/saAis.h ../include/saClm.h
|
||||
clm.o: ../include/saAis.h ../include/ipc_gen.h ../exec/totemip.h
|
||||
clm.o: ../include/ipc_clm.h ../include/saClm.h ../include/ipc_gen.h
|
||||
clm.o: ../include/mar_clm.h ../include/mar_gen.h ../include/mar_gen.h
|
||||
clm.o: ../include/mar_clm.h ../include/list.h ../include/queue.h
|
||||
clm.o: ../lcr/lcr_comp.h aispoll.h totempg.h totemsrp.h main.h mainconfig.h
|
||||
clm.o: objdb.h mempool.h service.h ../include/swab.h print.h
|
||||
clm.o: objdb.h mempool.h service.h ../include/swab.h logsys.h
|
||||
ckpt.o: ../include/saAis.h ../include/saCkpt.h ../include/ipc_ckpt.h
|
||||
ckpt.o: ../include/saAis.h ../include/saCkpt.h ../include/ipc_gen.h
|
||||
ckpt.o: ../include/list.h ../include/queue.h ../include/hdb.h
|
||||
ckpt.o: ../lcr/lcr_comp.h aispoll.h service.h totem.h totemip.h objdb.h
|
||||
ckpt.o: mempool.h util.h main.h ../include/saClm.h ../include/ipc_gen.h
|
||||
ckpt.o: ../exec/totemip.h mainconfig.h totemsrp.h totempg.h print.h
|
||||
ckpt.o: ../exec/totemip.h mainconfig.h totemsrp.h totempg.h logsys.h
|
||||
evt.o: ../include/hdb.h ../include/ipc_evt.h ../include/saAis.h
|
||||
evt.o: ../include/saEvt.h ../include/saClm.h ../include/ipc_gen.h
|
||||
evt.o: ../include/list.h ../include/queue.h ../lcr/lcr_comp.h util.h
|
||||
evt.o: ../include/saAis.h service.h totem.h totemip.h objdb.h aispoll.h
|
||||
evt.o: mempool.h main.h ../include/saClm.h ../include/ipc_gen.h
|
||||
evt.o: ../exec/totemip.h mainconfig.h totemsrp.h totempg.h ../include/swab.h print.h
|
||||
evt.o: ../exec/totemip.h mainconfig.h totemsrp.h totempg.h ../include/swab.h logsys.h
|
||||
lck.o: service.h totem.h totemip.h objdb.h ../include/saAis.h
|
||||
lck.o: ../include/saLck.h ../include/ipc_lck.h ../include/saAis.h
|
||||
lck.o: ../include/saLck.h ../include/ipc_gen.h ../include/list.h
|
||||
lck.o: ../include/queue.h ../lcr/lcr_comp.h aispoll.h mempool.h util.h main.h
|
||||
lck.o: ../include/saClm.h ../include/ipc_gen.h ../exec/totemip.h mainconfig.h
|
||||
lck.o: totemsrp.h totempg.h print.h
|
||||
lck.o: totemsrp.h totempg.h logsys.h
|
||||
msg.o: ../include/saAis.h ../include/saMsg.h ../include/ipc_msg.h
|
||||
msg.o: ../include/saAis.h ../include/saMsg.h ../include/ipc_gen.h
|
||||
msg.o: ../include/list.h ../include/queue.h ../lcr/lcr_comp.h service.h
|
||||
msg.o: totem.h totemip.h objdb.h aispoll.h mempool.h util.h main.h
|
||||
msg.o: ../include/saClm.h ../include/ipc_gen.h ../exec/totemip.h mainconfig.h
|
||||
msg.o: totemsrp.h totempg.h print.h
|
||||
msg.o: totemsrp.h totempg.h logsys.h
|
||||
cfg.o: ../include/saAis.h ../include/cfg.h ../include/saAis.h
|
||||
cfg.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_cfg.h
|
||||
cfg.o: ../include/ipc_gen.h ../include/cfg.h ../include/list.h
|
||||
cfg.o: ../include/queue.h ../lcr/lcr_comp.h service.h totem.h totemip.h
|
||||
cfg.o: objdb.h totempg.h aispoll.h totemsrp.h mempool.h util.h print.h
|
||||
cfg.o: objdb.h totempg.h aispoll.h totemsrp.h mempool.h util.h logsys.h
|
||||
cfg.o: mainconfig.h
|
||||
cpg.o: ../include/saAis.h ../include/saClm.h ../include/saAis.h
|
||||
cpg.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_cpg.h
|
||||
cpg.o: ../include/ipc_gen.h ../include/list.h ../include/queue.h
|
||||
cpg.o: ../lcr/lcr_comp.h aispoll.h totempg.h totemsrp.h totem.h totemip.h
|
||||
cpg.o: main.h mainconfig.h objdb.h mempool.h service.h jhash.h ../include/swab.h print.h
|
||||
cpg.o: main.h mainconfig.h objdb.h mempool.h service.h jhash.h ../include/swab.h logsys.h
|
||||
aisparser.o: ../lcr/lcr_comp.h objdb.h config.h mempool.h ../include/list.h
|
||||
aisparser.o: util.h ../include/saAis.h
|
||||
vsf_ykd.o: main.h ../include/saAis.h ../include/saClm.h ../include/saAis.h
|
||||
vsf_ykd.o: ../include/queue.h ../include/ipc_gen.h ../exec/totemip.h
|
||||
vsf_ykd.o: mainconfig.h ../include/list.h aispoll.h totemsrp.h totem.h
|
||||
vsf_ykd.o: totemip.h totempg.h objdb.h print.h ../include/swab.h vsf.h ../lcr/lcr_comp.h
|
||||
vsf_ykd.o: totemip.h totempg.h objdb.h logsys.h ../include/swab.h vsf.h ../lcr/lcr_comp.h
|
||||
amf.o: ../include/saAis.h ../include/saAmf.h ../include/saAis.h
|
||||
amf.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_amf.h
|
||||
amf.o: ../include/ipc_gen.h ../include/saAmf.h ../include/list.h
|
||||
amf.o: ../lcr/lcr_comp.h totempg.h aispoll.h totemsrp.h totem.h totemip.h
|
||||
amf.o: mempool.h util.h amf.h objdb.h main.h ../include/saClm.h
|
||||
amf.o: ../include/queue.h mainconfig.h service.h print.h
|
||||
amf.o: ../include/queue.h mainconfig.h service.h logsys.h
|
||||
amfutil.o: ../include/saAis.h ../include/saAmf.h ../include/saAis.h
|
||||
amfutil.o: ../include/ipc_amf.h ../include/ipc_gen.h ../include/saAmf.h
|
||||
amfutil.o: ../include/list.h util.h amf.h ../include/ipc_gen.h
|
||||
amfutil.o: ../exec/totemip.h aispoll.h objdb.h totem.h totemip.h print.h
|
||||
amfutil.o: ../exec/totemip.h aispoll.h objdb.h totem.h totemip.h logsys.h
|
||||
amfutil.o: mainconfig.h totemsrp.h totempg.h
|
||||
amfcluster.o: print.h mainconfig.h ../include/saAis.h ../include/list.h
|
||||
amfcluster.o: logsys.h mainconfig.h ../include/saAis.h ../include/list.h
|
||||
amfcluster.o: aispoll.h totemsrp.h totem.h totemip.h totempg.h objdb.h amf.h
|
||||
amfcluster.o: ../include/saAmf.h ../include/saAis.h ../include/ipc_gen.h
|
||||
amfcluster.o: ../exec/totemip.h util.h main.h ../include/saClm.h
|
||||
amfcluster.o: ../include/queue.h
|
||||
amfapp.o: amf.h ../include/saAis.h ../include/saAmf.h
|
||||
amfapp.o: ../include/saAis.h ../include/list.h ../include/ipc_gen.h
|
||||
amfapp.o: ../exec/totemip.h aispoll.h objdb.h print.h mainconfig.h
|
||||
amfapp.o: ../exec/totemip.h aispoll.h objdb.h logsys.h mainconfig.h
|
||||
amfapp.o: totemsrp.h totem.h totemip.h totempg.h
|
||||
amfsg.o: amf.h ../include/saAis.h ../include/saAmf.h ../include/saAis.h
|
||||
amfsg.o: ../include/list.h ../include/ipc_gen.h ../exec/totemip.h aispoll.h
|
||||
amfsg.o: objdb.h print.h mainconfig.h totemsrp.h totem.h totemip.h totempg.h
|
||||
amfsg.o: objdb.h logsys.h mainconfig.h totemsrp.h totem.h totemip.h totempg.h
|
||||
amfsg.o: main.h ../include/saClm.h ../include/queue.h
|
||||
amfsu.o: amf.h ../include/saAis.h ../include/saAmf.h ../include/saAis.h
|
||||
amfsu.o: ../include/list.h ../include/ipc_gen.h ../exec/totemip.h aispoll.h
|
||||
amfsu.o: objdb.h util.h print.h mainconfig.h totemsrp.h totem.h totemip.h
|
||||
amfsu.o: objdb.h util.h logsys.h mainconfig.h totemsrp.h totem.h totemip.h
|
||||
amfsu.o: totempg.h main.h ../include/saClm.h ../include/queue.h
|
||||
amfcomp.o: ../include/saAis.h ../include/saAmf.h ../include/saAis.h
|
||||
amfcomp.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_amf.h
|
||||
amfcomp.o: ../include/ipc_gen.h ../include/saAmf.h totempg.h aispoll.h
|
||||
amfcomp.o: totemsrp.h totem.h totemip.h main.h ../include/saClm.h
|
||||
amfcomp.o: ../include/queue.h mainconfig.h ../include/list.h objdb.h
|
||||
amfcomp.o: service.h util.h amf.h print.h
|
||||
amfcomp.o: service.h util.h amf.h logsys.h
|
||||
amfsi.o: amf.h ../include/saAis.h ../include/saAmf.h ../include/saAis.h
|
||||
amfsi.o: ../include/list.h ../include/ipc_gen.h ../exec/totemip.h aispoll.h
|
||||
amfsi.o: objdb.h print.h mainconfig.h totemsrp.h totem.h totemip.h totempg.h
|
||||
amfsi.o: objdb.h logsys.h mainconfig.h totemsrp.h totem.h totemip.h totempg.h
|
||||
|
15
exec/amf.c
15
exec/amf.c
@ -153,9 +153,11 @@
|
||||
#include "ipc.h"
|
||||
#include "service.h"
|
||||
#include "objdb.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "sync.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("AMF", LOG_INFO);
|
||||
|
||||
#ifdef AMFTEST
|
||||
#define static
|
||||
#endif
|
||||
@ -1305,8 +1307,6 @@ static void amf_sync_activate (void)
|
||||
*/
|
||||
static int amf_exec_init_fn (struct objdb_iface_ver0 *objdb)
|
||||
{
|
||||
log_init ("AMF");
|
||||
|
||||
if (gethostname (hostname, sizeof (hostname)) == -1) {
|
||||
log_printf (LOG_LEVEL_ERROR, "gethostname failed: %d", errno);
|
||||
openais_exit_error (AIS_DONE_FATAL_ERR);
|
||||
@ -1319,15 +1319,6 @@ static int amf_exec_init_fn (struct objdb_iface_ver0 *objdb)
|
||||
|
||||
sync_state_set (IDLE);
|
||||
|
||||
amf_cluster_init();
|
||||
amf_node_init();
|
||||
amf_application_init();
|
||||
amf_sg_init();
|
||||
amf_su_init();
|
||||
amf_comp_init();
|
||||
amf_si_init();
|
||||
amf_util_init ();
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -699,7 +699,6 @@ extern char *amf_deserialize_SaUint32T (char *buf, SaUint32T *num);
|
||||
extern char *amf_deserialize_SaUint64T (char *buf, SaUint64T *num);
|
||||
extern char *amf_deserialize_opaque (char *buf, void *dst, int *cnt);
|
||||
extern int amf_msg_mcast (int msg_id, void *buf, size_t len);
|
||||
extern void amf_util_init (void);
|
||||
extern void amf_fifo_put (int entry_type, amf_fifo_t **root,
|
||||
int size_of_data, void *data);
|
||||
extern int amf_fifo_get (amf_fifo_t **root, void *data);
|
||||
@ -710,7 +709,6 @@ extern void amf_call_function_asynchronous (async_func_t async_func, void *param
|
||||
|
||||
/* General methods */
|
||||
extern struct amf_node *amf_node_new (struct amf_cluster *cluster, char *name);
|
||||
extern void amf_node_init (void);
|
||||
extern void *amf_node_serialize (struct amf_node *node, int *len);
|
||||
extern struct amf_node *amf_node_deserialize (
|
||||
struct amf_cluster *cluster, char *buf);
|
||||
@ -752,7 +750,6 @@ extern void timer_function_node_probation_period_expired (void *node);
|
||||
/* amfcluster.c */
|
||||
|
||||
/* General methods */
|
||||
extern void amf_cluster_init (void);
|
||||
extern struct amf_cluster *amf_cluster_new (void);
|
||||
extern void *amf_cluster_serialize (struct amf_cluster *cluster, int *len);
|
||||
extern struct amf_cluster *amf_cluster_deserialize (char *buf);
|
||||
@ -785,7 +782,6 @@ extern void amf_cluster_application_workload_assigned (
|
||||
/* amfapp.c */
|
||||
|
||||
/* General methods */
|
||||
extern void amf_application_init (void);
|
||||
extern struct amf_application *amf_application_find (
|
||||
struct amf_cluster *cluster, char *name);
|
||||
extern struct amf_application *amf_application_new (
|
||||
@ -815,7 +811,6 @@ extern void amf_application_sg_assigned (
|
||||
/* amfsg.c */
|
||||
|
||||
/* General methods */
|
||||
extern void amf_sg_init (void);
|
||||
extern struct amf_sg *amf_sg_find (struct amf_application *app, char *name);
|
||||
extern struct amf_sg *amf_sg_new (struct amf_application *app, char *name);
|
||||
extern void amf_sg_delete (struct amf_sg *sg);
|
||||
@ -862,7 +857,6 @@ extern void amf_sg_si_activated (
|
||||
/* amfsu.c */
|
||||
|
||||
/* General methods */
|
||||
extern void amf_su_init (void);
|
||||
extern struct amf_su *amf_su_find (
|
||||
struct amf_cluster *cluster, SaNameT *name);
|
||||
extern struct amf_su *amf_su_new (struct amf_sg *sg, char *name);
|
||||
@ -918,7 +912,6 @@ extern int amf_su_instantiate (struct amf_su *su);
|
||||
/* amfcomp.c */
|
||||
|
||||
/* General methods */
|
||||
extern void amf_comp_init (void);
|
||||
extern struct amf_comp *amf_comp_new (struct amf_su *su, char *name);
|
||||
extern void amf_comp_delete (struct amf_comp *comp);
|
||||
extern char *amf_comp_dn_make (struct amf_comp *comp, SaNameT *name);
|
||||
@ -1046,7 +1039,6 @@ extern void mcast_error_report_from_pm (
|
||||
/* amfsi.c */
|
||||
|
||||
/* General methods */
|
||||
extern void amf_si_init (void);
|
||||
extern struct amf_si *amf_si_find (struct amf_application *app, char *name);
|
||||
extern struct amf_si *amf_si_new (struct amf_application *app, char *name);
|
||||
extern void amf_si_delete (struct amf_si *si);
|
||||
|
@ -127,9 +127,11 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "amf.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "util.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("AMF", LOG_INFO);
|
||||
|
||||
typedef struct application_event {
|
||||
amf_application_event_type_t event_type;
|
||||
amf_application_t *app;
|
||||
@ -456,11 +458,6 @@ void amf_application_sg_assigned (
|
||||
* General methods
|
||||
*****************************************************************************/
|
||||
|
||||
void amf_application_init (void)
|
||||
{
|
||||
log_init ("AMF");
|
||||
}
|
||||
|
||||
struct amf_application *amf_application_new (struct amf_cluster *cluster) {
|
||||
struct amf_application *app = amf_calloc (1,
|
||||
sizeof (struct amf_application));
|
||||
|
@ -143,12 +143,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "amf.h"
|
||||
#include "util.h"
|
||||
#include "main.h"
|
||||
#include "service.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("AMF", LOG_INFO);
|
||||
|
||||
typedef struct cluster_event {
|
||||
amf_cluster_event_type_t event_type;
|
||||
amf_cluster_t *cluster;
|
||||
@ -495,11 +497,6 @@ void amf_cluster_application_workload_assigned (
|
||||
* General methods
|
||||
*****************************************************************************/
|
||||
|
||||
void amf_cluster_init (void)
|
||||
{
|
||||
log_init ("AMF");
|
||||
}
|
||||
|
||||
struct amf_cluster *amf_cluster_new (void)
|
||||
{
|
||||
struct amf_cluster *cluster = amf_calloc (1,
|
||||
|
@ -144,9 +144,11 @@
|
||||
#include "service.h"
|
||||
#include "util.h"
|
||||
#include "amf.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "main.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("AMF", LOG_INFO);
|
||||
|
||||
enum clc_command_run_operation_type {
|
||||
CLC_COMMAND_RUN_OPERATION_TYPE_INSTANTIATE = 1,
|
||||
CLC_COMMAND_RUN_OPERATION_TYPE_TERMINATE = 2,
|
||||
@ -2296,11 +2298,6 @@ out:
|
||||
return error;
|
||||
}
|
||||
|
||||
void amf_comp_init (void)
|
||||
{
|
||||
log_init ("AMF");
|
||||
}
|
||||
|
||||
void amf_comp_operational_state_set (struct amf_comp *comp,
|
||||
SaAmfOperationalStateT oper_state)
|
||||
{
|
||||
|
@ -194,9 +194,11 @@
|
||||
#include <unistd.h>
|
||||
#include "amf.h"
|
||||
#include "util.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "main.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("AMF", LOG_INFO)
|
||||
|
||||
/******************************************************************************
|
||||
* Internal (static) utility functions
|
||||
*****************************************************************************/
|
||||
@ -668,12 +670,6 @@ void amf_node_sg_failed_over (struct amf_node *node, struct amf_sg *sg_in)
|
||||
* General methods
|
||||
*****************************************************************************/
|
||||
|
||||
void amf_node_init (void)
|
||||
{
|
||||
log_init ("AMF");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Node constructor
|
||||
* @param cluster
|
||||
|
@ -366,10 +366,12 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "amf.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "main.h"
|
||||
#include "util.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("AMF", LOG_INFO);
|
||||
|
||||
static int assign_si (struct amf_sg *sg, int dependency_level);
|
||||
static void acsm_enter_activating_standby (struct amf_sg *sg);
|
||||
static void delete_si_assignments_in_scope (struct amf_sg *sg);
|
||||
@ -2701,11 +2703,6 @@ static void standby_su_activated_cbfn (
|
||||
* General methods
|
||||
*****************************************************************************/
|
||||
|
||||
void amf_sg_init (void)
|
||||
{
|
||||
log_init ("AMF");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for SG objects. Adds SG to the list owned by
|
||||
* the specified application. Always returns a valid SG
|
||||
|
@ -114,11 +114,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "amf.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "util.h"
|
||||
#include "aispoll.h"
|
||||
#include "main.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("AMF", LOG_INFO);
|
||||
|
||||
/**
|
||||
* Check that all CSI assignments belonging to an SI assignment
|
||||
* has been removed.
|
||||
@ -292,11 +294,6 @@ char *amf_csi_dn_make (struct amf_csi *csi, SaNameT *name)
|
||||
return(char *)name->value;
|
||||
}
|
||||
|
||||
void amf_si_init (void)
|
||||
{
|
||||
log_init ("AMF");
|
||||
}
|
||||
|
||||
void amf_si_comp_set_ha_state_done (
|
||||
struct amf_si *si, struct amf_csi_assignment *csi_assignment)
|
||||
{
|
||||
|
@ -378,9 +378,11 @@
|
||||
|
||||
#include "amf.h"
|
||||
#include "util.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "main.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("AMF", LOG_INFO);
|
||||
|
||||
static int terminate_all_components_in_level (struct amf_su *su,
|
||||
SaUint32T current_instantiation_level);
|
||||
static int are_all_comps_in_level_uninst_or_term_failed (struct amf_su *su);
|
||||
@ -1358,11 +1360,6 @@ static void si_ha_state_assumed_cbfn (
|
||||
* General methods
|
||||
*****************************************************************************/
|
||||
|
||||
void amf_su_init (void)
|
||||
{
|
||||
log_init ("AMF");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for SU objects. Adds SU last in the ordered
|
||||
* list owned by the specified SG. Always returns a
|
||||
|
@ -59,11 +59,13 @@
|
||||
#include "util.h"
|
||||
#include "amf.h"
|
||||
#include "totem.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "aispoll.h"
|
||||
#include "main.h"
|
||||
#include "service.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("AMF", LOG_INFO);
|
||||
|
||||
#ifndef OPENAIS_CLUSTER_STARTUP_TIMEOUT
|
||||
#define OPENAIS_CLUSTER_STARTUP_TIMEOUT 5000
|
||||
#endif
|
||||
@ -1378,11 +1380,6 @@ int amf_msg_mcast (int msg_id, void *buf, size_t len)
|
||||
return res;
|
||||
}
|
||||
|
||||
void amf_util_init (void)
|
||||
{
|
||||
log_init ("AMF");
|
||||
}
|
||||
|
||||
void amf_fifo_put (int entry_type, amf_fifo_t **root, int size_of_data,
|
||||
void *data)
|
||||
{
|
||||
|
@ -62,9 +62,11 @@
|
||||
#include "totempg.h"
|
||||
#include "mempool.h"
|
||||
#include "util.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "main.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("AMF", LOG_INFO);
|
||||
|
||||
enum cfg_message_req_types {
|
||||
MESSAGE_REQ_EXEC_CFG_RINGREENABLE = 0
|
||||
};
|
||||
@ -226,9 +228,9 @@ struct req_exec_cfg_ringreenable {
|
||||
|
||||
static int cfg_exec_init_fn (struct objdb_iface_ver0 *objdb)
|
||||
{
|
||||
log_init ("CFG");
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void cfg_confchg_fn (
|
||||
enum totem_configuration_type configuration_type,
|
||||
unsigned int *member_list, int member_list_entries,
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 MontaVista Software, Inc.
|
||||
* Copyright (c) 2006 Red Hat, Inc.
|
||||
* Copyright (c) 2006-2007 Red Hat, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -63,7 +63,9 @@
|
||||
#include "main.h"
|
||||
#include "ipc.h"
|
||||
#include "totempg.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("CKPT", LOG_INFO);
|
||||
|
||||
#define CKPT_MAX_SECTION_DATA_SEND (1024*400)
|
||||
|
||||
@ -1066,8 +1068,6 @@ int ckpt_checkpoint_close (
|
||||
|
||||
static int ckpt_exec_init_fn (struct objdb_iface_ver0 *objdb)
|
||||
{
|
||||
log_init ("CKPT");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2006 MontaVista Software, Inc.
|
||||
* Copyright (c) 2006 Red Hat, Inc.
|
||||
* Copyright (c) 2006-2007 Red Hat, Inc.
|
||||
* Copyright (C) 2006 Sun Microsystems, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
@ -73,7 +73,10 @@
|
||||
#include "ipc.h"
|
||||
#include "mempool.h"
|
||||
#include "service.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("CLM", LOG_INFO);
|
||||
|
||||
|
||||
enum clm_message_req_types {
|
||||
MESSAGE_REQ_EXEC_CLM_NODEJOIN = 0
|
||||
@ -305,8 +308,6 @@ static void my_cluster_node_load (void)
|
||||
|
||||
static int clm_exec_init_fn (struct objdb_iface_ver0 *objdb)
|
||||
{
|
||||
log_init ("CLM");
|
||||
|
||||
memset (cluster_node_entries, 0,
|
||||
sizeof (mar_clm_cluster_node_t) * PROCESSOR_COUNT_MAX);
|
||||
|
||||
|
@ -70,7 +70,9 @@
|
||||
#include "swab.h"
|
||||
#include "ipc.h"
|
||||
#include "flow.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("CPG", LOG_INFO);
|
||||
|
||||
#define GROUP_HASH_SIZE 32
|
||||
|
||||
@ -465,8 +467,6 @@ static int cpg_exec_init_fn (struct objdb_iface_ver0 *objdb)
|
||||
{
|
||||
int i;
|
||||
|
||||
log_init ("CPG");
|
||||
|
||||
for (i=0; i<GROUP_HASH_SIZE; i++) {
|
||||
list_init(&group_lists[i]);
|
||||
}
|
||||
|
10
exec/evs.c
10
exec/evs.c
@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2006 MontaVista Software, Inc.
|
||||
* Copyright (c) 2006 Red Hat, Inc.
|
||||
* Copyright (c) 2006-2007 Red Hat, Inc.
|
||||
* Copyright (c) 2006 Sun Microsystems, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Steven Dake (sdake@mvista.com)
|
||||
* Author: Steven Dake (sdake@redhat.com)
|
||||
*
|
||||
* This software licensed under BSD license, the text of which follows:
|
||||
*
|
||||
@ -62,7 +62,9 @@
|
||||
#include "ipc.h"
|
||||
#include "mempool.h"
|
||||
#include "service.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("EVS", LOG_INFO);
|
||||
|
||||
enum evs_exec_message_req_types {
|
||||
MESSAGE_REQ_EXEC_EVS_MCAST = 0
|
||||
@ -203,8 +205,6 @@ static int evs_exec_init_fn(struct objdb_iface_ver0 *objdb)
|
||||
{
|
||||
(void) objdb;
|
||||
|
||||
log_init ("EVS");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -61,10 +61,11 @@
|
||||
#include "ipc.h"
|
||||
#include "totempg.h"
|
||||
#include "swab.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "tlist.h"
|
||||
#include "timer.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("EVT", LOG_INFO);
|
||||
/*
|
||||
* event instance structure. Contains information about the
|
||||
* active connection to the API library.
|
||||
@ -3108,7 +3109,6 @@ static int evt_exec_init(struct objdb_iface_ver0 *objdb)
|
||||
unsigned int object_service_handle;
|
||||
char *value;
|
||||
|
||||
log_init ("EVT");
|
||||
log_printf(LOG_LEVEL_DEBUG, "Evt exec init request\n");
|
||||
|
||||
objdb->object_find_reset (OBJECT_PARENT_HANDLE);
|
||||
|
@ -50,10 +50,12 @@
|
||||
#include "flow.h"
|
||||
#include "totem.h"
|
||||
#include "totempg.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "hdb.h"
|
||||
#include "../include/list.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("FLOW", LOG_INFO);
|
||||
|
||||
struct flow_control_instance {
|
||||
struct list_head list_head;
|
||||
unsigned int service;
|
||||
@ -245,8 +247,6 @@ unsigned int openais_flow_control_initialize (void)
|
||||
{
|
||||
unsigned int res;
|
||||
|
||||
log_init ("FLOW");
|
||||
|
||||
res = totempg_groups_initialize (
|
||||
&flow_control_handle,
|
||||
flow_control_deliver_fn,
|
||||
|
@ -79,10 +79,12 @@
|
||||
#include "config.h"
|
||||
#include "tlist.h"
|
||||
#define LOG_SERVICE LOG_SERVICE_IPC
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
|
||||
#include "util.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("IPC", LOG_INFO);
|
||||
|
||||
#ifdef OPENAIS_SOLARIS
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
@ -1026,8 +1028,6 @@ void openais_ipc_init (
|
||||
struct sockaddr_un un_addr;
|
||||
int res;
|
||||
|
||||
log_init ("IPC");
|
||||
|
||||
ipc_serialize_lock_fn = serialize_lock_fn;
|
||||
|
||||
ipc_serialize_unlock_fn = serialize_unlock_fn;
|
||||
|
@ -61,8 +61,9 @@
|
||||
#include "main.h"
|
||||
#include "ipc.h"
|
||||
#include "totempg.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("LCK", LOG_INFO);
|
||||
|
||||
enum lck_message_req_types {
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCEOPEN = 0,
|
||||
@ -675,8 +676,6 @@ void lck_resource_cleanup_remove (
|
||||
|
||||
static int lck_exec_init_fn (struct objdb_iface_ver0 *objdb)
|
||||
{
|
||||
log_init ("LCK");
|
||||
|
||||
/*
|
||||
* Initialize the saved ring ID.
|
||||
*/
|
||||
|
613
exec/logsys.c
Normal file
613
exec/logsys.c
Normal file
@ -0,0 +1,613 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2004 MontaVista Software, Inc.
|
||||
* Copyright (c) 2006-2007 Red Hat, Inc.
|
||||
*
|
||||
* Author: Steven Dake (sdake@redhat.com)
|
||||
* Author: Lon Hohberger (lhh@redhat.com)
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software licensed under BSD license, the text of which follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#if defined(OPENAIS_LINUX)
|
||||
#include <linux/un.h>
|
||||
#endif
|
||||
#if defined(OPENAIS_BSD) || defined(OPENAIS_DARWIN)
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
#define SYSLOG_NAMES
|
||||
#include <syslog.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "swab.h"
|
||||
#include "logsys.h"
|
||||
#include "totemip.h"
|
||||
//#include "../include/saAis.h"
|
||||
#include "mainconfig.h"
|
||||
#include "wthread.h"
|
||||
|
||||
/*
|
||||
* Configuration parameters for logging system
|
||||
*/
|
||||
static char *logsys_name = NULL;
|
||||
|
||||
static unsigned int logsys_mode = 0;
|
||||
|
||||
static char *logsys_file = NULL;
|
||||
|
||||
static FILE *logsys_file_fp = NULL;
|
||||
|
||||
static int logsys_facility = LOG_DAEMON;
|
||||
|
||||
static int logsys_nosubsys = 0;
|
||||
|
||||
static int logsys_wthread_active = 0;
|
||||
|
||||
static pthread_mutex_t logsys_config_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static pthread_mutex_t logsys_new_log_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static struct worker_thread_group log_thread_group;
|
||||
|
||||
static unsigned int dropped_log_entries = 0;
|
||||
|
||||
#ifndef MAX_LOGGERS
|
||||
#define MAX_LOGGERS 32
|
||||
#endif
|
||||
struct logsys_logger logsys_loggers[MAX_LOGGERS];
|
||||
|
||||
|
||||
struct log_entry {
|
||||
char *file;
|
||||
int line;
|
||||
int priority;
|
||||
char str[128];
|
||||
struct log_entry *next;
|
||||
};
|
||||
|
||||
static struct log_entry *head;
|
||||
|
||||
static struct log_entry *tail;
|
||||
|
||||
struct log_data {
|
||||
unsigned int syslog_pos;
|
||||
unsigned int priority;
|
||||
char *log_string;
|
||||
};
|
||||
|
||||
enum logsys_config_mutex_state {
|
||||
LOGSYS_CONFIG_MUTEX_LOCKED,
|
||||
LOGSYS_CONFIG_MUTEX_UNLOCKED
|
||||
};
|
||||
|
||||
static void logsys_atexit (void);
|
||||
|
||||
#define LEVELMASK 0x07 /* 3 bits */
|
||||
#define LOG_LEVEL(p) ((p) & LEVELMASK)
|
||||
#define LOGSYS_IDMASK (0x3f << 3) /* 6 bits */
|
||||
#define LOG_ID(p) (((p) & LOGSYS_IDMASK) >> 3)
|
||||
|
||||
static void logsys_buffer_flush (void);
|
||||
|
||||
void _logsys_nosubsys_set (void)
|
||||
{
|
||||
logsys_nosubsys = 1;
|
||||
}
|
||||
|
||||
int logsys_facility_id_get (const char *name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; facilitynames[i].c_name != NULL; i++) {
|
||||
if (strcasecmp(name, facilitynames[i].c_name) == 0) {
|
||||
return (facilitynames[i].c_val);
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int logsys_priority_id_get (const char *name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; prioritynames[i].c_name != NULL; i++) {
|
||||
if (strcasecmp(name, prioritynames[i].c_name) == 0) {
|
||||
return (prioritynames[i].c_val);
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static inline char *logsys_priority_name_get (unsigned int priority)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; prioritynames[i].c_name != NULL; i++) {
|
||||
if (priority == prioritynames[i].c_val) {
|
||||
return (prioritynames[i].c_name);
|
||||
}
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
unsigned int logsys_config_subsys_set (
|
||||
const char *subsys,
|
||||
unsigned int tags,
|
||||
unsigned int priority)
|
||||
{
|
||||
int i;
|
||||
|
||||
pthread_mutex_lock (&logsys_config_mutex);
|
||||
for (i = 0; i < MAX_LOGGERS; i++) {
|
||||
if (strcmp (logsys_loggers[i].subsys, subsys) == 0) {
|
||||
logsys_loggers[i].tags = tags;
|
||||
logsys_loggers[i].priority = priority;
|
||||
|
||||
if (priority > logsys_loggers[i].priority) {
|
||||
logsys_loggers[i].priority = priority;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == MAX_LOGGERS) {
|
||||
for (i = 0; i < MAX_LOGGERS; i++) {
|
||||
if (strcmp (logsys_loggers[i].subsys, "") == 0) {
|
||||
strncpy (logsys_loggers[i].subsys, subsys,
|
||||
sizeof(logsys_loggers[i].subsys));
|
||||
logsys_loggers[i].tags = tags;
|
||||
logsys_loggers[i].priority = priority;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(i < MAX_LOGGERS);
|
||||
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
return i;
|
||||
}
|
||||
|
||||
inline int logsys_mkpri (int priority, int id)
|
||||
{
|
||||
return (((id) << 3) | (priority));
|
||||
}
|
||||
|
||||
int logsys_config_subsys_get (
|
||||
const char *subsys,
|
||||
unsigned int *tags,
|
||||
unsigned int *priority)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
pthread_mutex_lock (&logsys_config_mutex);
|
||||
|
||||
for (i = 0; i < MAX_LOGGERS; i++) {
|
||||
if (strcmp (logsys_loggers[i].subsys, subsys) == 0) {
|
||||
*tags = logsys_loggers[i].tags;
|
||||
*priority = logsys_loggers[i].priority;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void buffered_log_printf (
|
||||
char *file,
|
||||
int line,
|
||||
int priority,
|
||||
char *format,
|
||||
va_list ap)
|
||||
{
|
||||
struct log_entry *entry = malloc(sizeof(struct log_entry));
|
||||
|
||||
entry->file = file;
|
||||
entry->line = line;
|
||||
entry->priority = priority;
|
||||
entry->next = NULL;
|
||||
if (head == NULL) {
|
||||
head = tail = entry;
|
||||
} else {
|
||||
tail->next = entry;
|
||||
tail = entry;
|
||||
}
|
||||
vsnprintf(entry->str, sizeof(entry->str), format, ap);
|
||||
}
|
||||
|
||||
static void log_printf_worker_fn (void *thread_data, void *work_item)
|
||||
{
|
||||
struct log_data *log_data = (struct log_data *)work_item;
|
||||
|
||||
pthread_mutex_lock (&logsys_config_mutex);
|
||||
/*
|
||||
* Output the log data
|
||||
*/
|
||||
if (logsys_mode & LOG_MODE_OUTPUT_FILE && logsys_file_fp != 0) {
|
||||
fprintf (logsys_file_fp, "%s", log_data->log_string);
|
||||
fflush (logsys_file_fp);
|
||||
}
|
||||
if (logsys_mode & LOG_MODE_OUTPUT_STDERR) {
|
||||
fprintf (stderr, "%s", log_data->log_string);
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
if (logsys_mode & LOG_MODE_OUTPUT_SYSLOG_THREADED) {
|
||||
syslog (log_data->priority,
|
||||
&log_data->log_string[log_data->syslog_pos]);
|
||||
}
|
||||
free (log_data->log_string);
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
}
|
||||
|
||||
static void _log_printf (
|
||||
enum logsys_config_mutex_state config_mutex_state,
|
||||
char *file,
|
||||
int line,
|
||||
int priority,
|
||||
int id,
|
||||
char *format,
|
||||
va_list ap)
|
||||
{
|
||||
char newstring[4096];
|
||||
char log_string[4096];
|
||||
char char_time[512];
|
||||
struct timeval tv;
|
||||
int i = 0;
|
||||
int len;
|
||||
struct log_data log_data;
|
||||
unsigned int res = 0;
|
||||
|
||||
assert (id < MAX_LOGGERS);
|
||||
|
||||
if (config_mutex_state == LOGSYS_CONFIG_MUTEX_UNLOCKED) {
|
||||
pthread_mutex_lock (&logsys_config_mutex);
|
||||
}
|
||||
pthread_mutex_lock (&logsys_new_log_mutex);
|
||||
/*
|
||||
** Buffer before log has been configured has been called.
|
||||
*/
|
||||
if (logsys_mode & LOG_MODE_BUFFER_BEFORE_CONFIG) {
|
||||
buffered_log_printf(file, line, priority, format, ap);
|
||||
pthread_mutex_unlock (&logsys_new_log_mutex);
|
||||
if (config_mutex_state == LOGSYS_CONFIG_MUTEX_UNLOCKED) {
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (((logsys_mode & LOG_MODE_OUTPUT_FILE) || (logsys_mode & LOG_MODE_OUTPUT_STDERR)) &&
|
||||
(logsys_mode & LOG_MODE_DISPLAY_TIMESTAMP)) {
|
||||
gettimeofday (&tv, NULL);
|
||||
strftime (char_time, sizeof (char_time), "%b %e %k:%M:%S",
|
||||
localtime (&tv.tv_sec));
|
||||
i = sprintf (newstring, "%s.%06ld ", char_time, (long)tv.tv_usec);
|
||||
}
|
||||
|
||||
if ((priority == LOG_LEVEL_DEBUG) || (logsys_mode & LOG_MODE_DISPLAY_FILELINE)) {
|
||||
sprintf (&newstring[i], "[%s:%04u] %s", file, line, format);
|
||||
} else {
|
||||
if (logsys_nosubsys == 1) {
|
||||
sprintf (&newstring[i], "%s", format);
|
||||
} else {
|
||||
sprintf (&newstring[i], "[%-5s] %s", logsys_loggers[id].subsys, format);
|
||||
}
|
||||
}
|
||||
if (dropped_log_entries) {
|
||||
/*
|
||||
* Get rid of \n if there is one
|
||||
*/
|
||||
if (newstring[strlen (newstring) - 1] == '\n') {
|
||||
newstring[strlen (newstring) - 1] = '\0';
|
||||
}
|
||||
len = sprintf (log_string,
|
||||
"%s - prior to this log entry, openais logger dropped '%d' messages because of overflow.", newstring, dropped_log_entries + 1);
|
||||
} else {
|
||||
len = vsprintf (log_string, newstring, ap);
|
||||
}
|
||||
|
||||
/*
|
||||
** add line feed if not done yet
|
||||
*/
|
||||
if (log_string[len - 1] != '\n') {
|
||||
log_string[len] = '\n';
|
||||
log_string[len + 1] = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* Create work thread data
|
||||
*/
|
||||
log_data.syslog_pos = i;
|
||||
log_data.priority = priority;
|
||||
log_data.log_string = strdup (log_string);
|
||||
if (log_data.log_string == NULL) {
|
||||
goto drop_log_msg;
|
||||
}
|
||||
|
||||
if (logsys_wthread_active) {
|
||||
res = worker_thread_group_work_add (&log_thread_group, &log_data);
|
||||
if (res == 0) {
|
||||
dropped_log_entries = 0;
|
||||
} else {
|
||||
dropped_log_entries += 1;
|
||||
}
|
||||
} else {
|
||||
log_printf_worker_fn (NULL, &log_data);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock (&logsys_new_log_mutex);
|
||||
if (config_mutex_state == LOGSYS_CONFIG_MUTEX_UNLOCKED) {
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
}
|
||||
return;
|
||||
|
||||
drop_log_msg:
|
||||
dropped_log_entries++;
|
||||
pthread_mutex_unlock (&logsys_new_log_mutex);
|
||||
if (config_mutex_state == LOGSYS_CONFIG_MUTEX_UNLOCKED) {
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int _logsys_subsys_create (
|
||||
const char *subsys,
|
||||
unsigned int priority)
|
||||
{
|
||||
assert (subsys != NULL);
|
||||
|
||||
return logsys_config_subsys_set (
|
||||
subsys,
|
||||
LOGSYS_TAG_LOG,
|
||||
priority);
|
||||
}
|
||||
|
||||
|
||||
void logsys_config_mode_set (unsigned int mode)
|
||||
{
|
||||
pthread_mutex_lock (&logsys_config_mutex);
|
||||
logsys_mode = mode;
|
||||
if (mode & LOG_MODE_FLUSH_AFTER_CONFIG) {
|
||||
logsys_mode = logsys_mode & ~LOG_MODE_FLUSH_AFTER_CONFIG;
|
||||
_logsys_wthread_create ();
|
||||
logsys_buffer_flush ();
|
||||
}
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
}
|
||||
|
||||
int logsys_config_file_set (char **error_string, char *file)
|
||||
{
|
||||
static char error_string_response[512];
|
||||
|
||||
if (file == NULL) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
pthread_mutex_lock (&logsys_new_log_mutex);
|
||||
pthread_mutex_lock (&logsys_config_mutex);
|
||||
|
||||
if (logsys_mode & LOG_MODE_OUTPUT_FILE) {
|
||||
logsys_file = file;
|
||||
if (logsys_file_fp != NULL) {
|
||||
fclose (logsys_file_fp);
|
||||
}
|
||||
logsys_file_fp = fopen (file, "a+");
|
||||
if (logsys_file_fp == 0) {
|
||||
sprintf (error_string_response,
|
||||
"Can't open logfile '%s' for reason (%s).\n",
|
||||
file, strerror (errno));
|
||||
*error_string = error_string_response;
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
pthread_mutex_unlock (&logsys_new_log_mutex);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
pthread_mutex_unlock (&logsys_new_log_mutex);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void logsys_config_facility_set (char *name, unsigned int facility)
|
||||
{
|
||||
pthread_mutex_lock (&logsys_new_log_mutex);
|
||||
pthread_mutex_lock (&logsys_config_mutex);
|
||||
|
||||
logsys_name = name;
|
||||
logsys_facility = facility;
|
||||
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
pthread_mutex_unlock (&logsys_new_log_mutex);
|
||||
}
|
||||
|
||||
void logsys_config_priority_set (unsigned int priority)
|
||||
{
|
||||
unsigned int tags;
|
||||
unsigned int dummy_priority;
|
||||
|
||||
pthread_mutex_lock (&logsys_new_log_mutex);
|
||||
pthread_mutex_lock (&logsys_config_mutex);
|
||||
|
||||
logsys_config_subsys_get ("MAIN", &tags, &dummy_priority);
|
||||
logsys_config_subsys_set ("MAIN", tags, priority);
|
||||
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
pthread_mutex_unlock (&logsys_new_log_mutex);
|
||||
}
|
||||
|
||||
int _logsys_wthread_create (void)
|
||||
{
|
||||
worker_thread_group_init (
|
||||
&log_thread_group,
|
||||
1,
|
||||
1024,
|
||||
sizeof (struct log_data),
|
||||
0,
|
||||
NULL,
|
||||
log_printf_worker_fn);
|
||||
|
||||
logsys_flush();
|
||||
|
||||
atexit (logsys_atexit);
|
||||
|
||||
if (logsys_mode & LOG_MODE_OUTPUT_SYSLOG_THREADED && logsys_name != NULL) {
|
||||
openlog (logsys_name, LOG_CONS|LOG_PID, logsys_facility);
|
||||
}
|
||||
|
||||
logsys_wthread_active = 1;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void logsys_log_printf (
|
||||
char *file,
|
||||
int line,
|
||||
int priority,
|
||||
char *format,
|
||||
...)
|
||||
{
|
||||
int id = LOG_ID(priority);
|
||||
int level = LOG_LEVEL(priority);
|
||||
va_list ap;
|
||||
|
||||
assert (id < MAX_LOGGERS);
|
||||
|
||||
if (LOG_LEVEL(priority) > logsys_loggers[id].priority) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_start (ap, format);
|
||||
_log_printf (LOGSYS_CONFIG_MUTEX_UNLOCKED, file, line, level, id,
|
||||
format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void logsys_log_printf_locked (
|
||||
char *file,
|
||||
int line,
|
||||
int priority,
|
||||
char *format,
|
||||
...)
|
||||
{
|
||||
int id = LOG_ID(priority);
|
||||
int level = LOG_LEVEL(priority);
|
||||
va_list ap;
|
||||
|
||||
assert (id < MAX_LOGGERS);
|
||||
|
||||
if (LOG_LEVEL(priority) > logsys_loggers[id].priority) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_start (ap, format);
|
||||
_log_printf (LOGSYS_CONFIG_MUTEX_LOCKED, file, line, level, id,
|
||||
format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void _logsys_log_printf2 (
|
||||
char *file,
|
||||
int line,
|
||||
int priority,
|
||||
int id,
|
||||
char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
assert (id < MAX_LOGGERS);
|
||||
|
||||
va_start (ap, format);
|
||||
_log_printf (LOGSYS_CONFIG_MUTEX_UNLOCKED, file, line, priority, id,
|
||||
format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void _logsys_trace (char *file, int line, int tag, int id, char *format, ...)
|
||||
{
|
||||
assert (id < MAX_LOGGERS);
|
||||
|
||||
pthread_mutex_lock (&logsys_config_mutex);
|
||||
|
||||
if (tag & logsys_loggers[id].tags) {
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, format);
|
||||
_log_printf (LOGSYS_CONFIG_MUTEX_LOCKED, file, line,
|
||||
LOG_LEVEL_DEBUG, id, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
pthread_mutex_unlock (&logsys_config_mutex);
|
||||
}
|
||||
|
||||
static void logsys_atexit (void)
|
||||
{
|
||||
if (logsys_wthread_active) {
|
||||
worker_thread_group_wait (&log_thread_group);
|
||||
}
|
||||
if (logsys_mode & LOG_MODE_OUTPUT_SYSLOG_THREADED) {
|
||||
closelog ();
|
||||
}
|
||||
}
|
||||
|
||||
static void logsys_buffer_flush (void)
|
||||
{
|
||||
struct log_entry *entry = head;
|
||||
struct log_entry *tmp;
|
||||
|
||||
if (logsys_mode & LOG_MODE_FLUSH_AFTER_CONFIG) {
|
||||
logsys_mode &= ~LOG_MODE_FLUSH_AFTER_CONFIG;
|
||||
|
||||
while (entry) {
|
||||
logsys_log_printf_locked (
|
||||
entry->file,
|
||||
entry->line,
|
||||
entry->priority,
|
||||
entry->str);
|
||||
tmp = entry;
|
||||
entry = entry->next;
|
||||
free (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
head = tail = NULL;
|
||||
logsys_flush();
|
||||
}
|
||||
|
||||
void logsys_flush (void)
|
||||
{
|
||||
worker_thread_group_wait (&log_thread_group);
|
||||
}
|
286
exec/logsys.h
Normal file
286
exec/logsys.h
Normal file
@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2004 MontaVista Software, Inc.
|
||||
* Copyright (c) 2006-2007 Red Hat, Inc.
|
||||
*
|
||||
* Author: Steven Dake (sdake@redhat.com)
|
||||
* Author: Lon Hohberger (lhh@redhat.com)
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software licensed under BSD license, the text of which follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef LOGSYS_H_DEFINED
|
||||
#define LOGSYS_H_DEFINED
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
|
||||
/*
|
||||
* MODE_OUTPUT_SYSLOG_* modes are mutually exclusive
|
||||
*/
|
||||
#define LOG_MODE_OUTPUT_FILE (1<<0)
|
||||
#define LOG_MODE_OUTPUT_STDERR (1<<1)
|
||||
#define LOG_MODE_OUTPUT_SYSLOG_THREADED (1<<2)
|
||||
#define LOG_MODE_OUTPUT_SYSLOG_LOSSY (1<<3)
|
||||
#define LOG_MODE_OUTPUT_SYSLOG_BLOCKING (1<<4)
|
||||
#define LOG_MODE_DISPLAY_PRIORITY (1<<5)
|
||||
#define LOG_MODE_DISPLAY_FILELINE (1<<6)
|
||||
#define LOG_MODE_DISPLAY_TIMESTAMP (1<<7)
|
||||
#define LOG_MODE_DISPLAY_DEBUG (1<<8)
|
||||
#define LOG_MODE_BUFFER_BEFORE_CONFIG (1<<9)
|
||||
#define LOG_MODE_FLUSH_AFTER_CONFIG (1<<10)
|
||||
|
||||
/*
|
||||
* Log priorities, compliant with syslog and SA Forum Log spec.
|
||||
*/
|
||||
#define LOG_LEVEL_EMERG LOG_EMERG
|
||||
#define LOG_LEVEL_ALERT LOG_ALERT
|
||||
#define LOG_LEVEL_CRIT LOG_CRIT
|
||||
#define LOG_LEVEL_ERROR LOG_ERR
|
||||
#define LOG_LEVEL_WARNING LOG_WARNING
|
||||
#define LOG_LEVEL_SECURITY LOG_WARNING // openais specific
|
||||
#define LOG_LEVEL_NOTICE LOG_NOTICE
|
||||
#define LOG_LEVEL_INFO LOG_INFO
|
||||
#define LOG_LEVEL_DEBUG LOG_DEBUG
|
||||
|
||||
/*
|
||||
** Log tags, used by _logsys_trace macros, uses 32 bits => 32 different tags
|
||||
*/
|
||||
#define LOGSYS_TAG_LOG (1<<0)
|
||||
#define LOGSYS_TAG_ENTER (1<<1)
|
||||
#define LOGSYS_TAG_LEAVE (1<<2)
|
||||
#define LOGSYS_TAG_TRACE1 (1<<3)
|
||||
#define LOGSYS_TAG_TRACE2 (1<<4)
|
||||
#define LOGSYS_TAG_TRACE3 (1<<5)
|
||||
#define LOGSYS_TAG_TRACE4 (1<<6)
|
||||
#define LOGSYS_TAG_TRACE5 (1<<7)
|
||||
#define LOGSYS_TAG_TRACE6 (1<<8)
|
||||
#define LOGSYS_TAG_TRACE7 (1<<9)
|
||||
#define LOGSYS_TAG_TRACE8 (1<<10)
|
||||
|
||||
/*
|
||||
* External API
|
||||
*/
|
||||
|
||||
struct logsys_logger {
|
||||
char subsys[6];
|
||||
unsigned int priority;
|
||||
unsigned int tags;
|
||||
unsigned int mode;
|
||||
};
|
||||
|
||||
extern struct logsys_logger logsys_loggers[];
|
||||
|
||||
extern inline int logsys_mkpri (int priority, int id);
|
||||
|
||||
extern void logsys_config_mode_set (
|
||||
unsigned int mode);
|
||||
|
||||
extern int logsys_config_file_set (
|
||||
char **error_string,
|
||||
char *file);
|
||||
|
||||
extern void logsys_config_facility_set (
|
||||
char *name,
|
||||
unsigned int facility);
|
||||
|
||||
extern void logsys_config_priority_set (
|
||||
unsigned int priority);
|
||||
|
||||
extern unsigned int logsys_config_subsys_set (
|
||||
const char *subsys,
|
||||
unsigned int tags,
|
||||
unsigned int priority);
|
||||
|
||||
extern int logsys_config_subsys_get (
|
||||
const char *subsys,
|
||||
unsigned int *tags,
|
||||
unsigned int *priority);
|
||||
|
||||
extern int logsys_facility_id_get (
|
||||
const char *name);
|
||||
|
||||
extern int logsys_priority_id_get (
|
||||
const char *name);
|
||||
|
||||
extern void logsys_flush (void);
|
||||
|
||||
extern void logsys_atsegv (void);
|
||||
|
||||
/*
|
||||
* Internal APIs that must be globally exported
|
||||
*/
|
||||
extern unsigned int _logsys_subsys_create (const char *ident,
|
||||
unsigned int priority);
|
||||
|
||||
extern void _logsys_nosubsys_set (void);
|
||||
|
||||
extern int _logsys_wthread_create (void);
|
||||
|
||||
extern void logsys_log_printf (char *file, int line, int priority,
|
||||
char *format, ...) __attribute__((format(printf, 4, 5)));
|
||||
|
||||
extern void _logsys_log_printf2 (char *file, int line, int priority,
|
||||
int id, char *format, ...) __attribute__((format(printf, 5, 6)));
|
||||
|
||||
extern void _logsys_trace (char *file, int line, int tag, int id,
|
||||
char *format, ...) __attribute__((format(printf, 5, 6)));
|
||||
|
||||
/*
|
||||
* External definitions
|
||||
*/
|
||||
#define LOGSYS_DECLARE_SYSTEM(name,mode,file,facility) \
|
||||
__attribute__ ((constructor)) static void logsys_system_init (void) \
|
||||
{ \
|
||||
char *error_string; \
|
||||
\
|
||||
logsys_config_mode_set (mode); \
|
||||
logsys_config_file_set (&error_string, (file)); \
|
||||
logsys_config_facility_set (name, (facility)); \
|
||||
if (((mode) & LOG_MODE_BUFFER_BEFORE_CONFIG) == 0) { \
|
||||
_logsys_wthread_create (); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define LOGSYS_DECLARE_NOSUBSYS(priority) \
|
||||
static unsigned int logsys_subsys_id __attribute__((unused)); \
|
||||
__attribute__ ((constructor)) static void logsys_nosubsys_init (void) \
|
||||
{ \
|
||||
_logsys_nosubsys_set(); \
|
||||
logsys_subsys_id = \
|
||||
_logsys_subsys_create ("MAIN", (priority)); \
|
||||
}
|
||||
|
||||
#define LOGSYS_DECLARE_SUBSYS(subsys,priority) \
|
||||
static unsigned int logsys_subsys_id __attribute__((unused)); \
|
||||
__attribute__ ((constructor)) static void logsys_subsys_init (void) \
|
||||
{ \
|
||||
logsys_subsys_id = \
|
||||
_logsys_subsys_create ((subsys), (priority)); \
|
||||
}
|
||||
|
||||
#define log_printf(lvl, format, args...) do { \
|
||||
if ((lvl) <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_log_printf2 (__FILE__, __LINE__, lvl, \
|
||||
logsys_subsys_id, (format), ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define dprintf(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_log_printf2 (__FILE__, __LINE__, LOG_DEBUG, \
|
||||
logsys_subsys_id, (format), ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define ENTER_VOID() do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_ENTER, \
|
||||
logsys_subsys_id, ">%s\n", __FUNCTION__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define ENTER(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_ENTER, \
|
||||
logsys_subsys_id, ">%s: " format, __FUNCTION__, \
|
||||
##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define LEAVE_VOID() do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_LEAVE, \
|
||||
logsys_subsys_id, "<%s\n", __FUNCTION__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define LEAVE(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_LEAVE, \
|
||||
logsys_subsys_id, "<%s: " format, \
|
||||
__FUNCTION__, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE1(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE1, \
|
||||
logsys_subsys_id, (format), ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE2(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE2, \
|
||||
logsys_subsys_id, (format), ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE3(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE3, \
|
||||
logsys_subsys_id, (format), ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE4(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE4, \
|
||||
logsys_subsys_id, (format), ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE5(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE5, \
|
||||
logsys_subsys_id, (format), ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE6(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE6, \
|
||||
logsys_subsys_id, (format), ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE7(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE7, \
|
||||
logsys_subsys_id, (format), ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE8(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
|
||||
_logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE8, \
|
||||
logsys_subsys_id, (format), ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#endif /* LOGSYS_H_DEFINED */
|
39
exec/main.c
39
exec/main.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2006 MontaVista Software, Inc.
|
||||
* Copyright (c) 2006 Red Hat, Inc..
|
||||
* Copyright (c) 2006 Red Hat, Inc.
|
||||
* Copyright (c) 2006 Sun Microsystems, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
@ -75,11 +75,18 @@
|
||||
#include "config.h"
|
||||
#include "ipc.h"
|
||||
#include "timer.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "util.h"
|
||||
#include "flow.h"
|
||||
#include "version.h"
|
||||
|
||||
LOGSYS_DECLARE_SYSTEM ("openais",
|
||||
LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_DISPLAY_DEBUG | LOG_MODE_BUFFER_BEFORE_CONFIG,
|
||||
NULL,
|
||||
LOG_DAEMON);
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("MAIN", LOG_INFO);
|
||||
|
||||
#define SERVER_BACKLOG 5
|
||||
|
||||
static int ais_uid = 0;
|
||||
@ -110,14 +117,14 @@ static void sigusr2_handler (int num)
|
||||
static void sigsegv_handler (int num)
|
||||
{
|
||||
signal (SIGSEGV, SIG_DFL);
|
||||
log_flush ();
|
||||
logsys_flush ();
|
||||
raise (SIGSEGV);
|
||||
}
|
||||
|
||||
static void sigabrt_handler (int num)
|
||||
{
|
||||
signal (SIGABRT, SIG_DFL);
|
||||
log_flush ();
|
||||
logsys_flush ();
|
||||
raise (SIGABRT);
|
||||
}
|
||||
|
||||
@ -390,7 +397,6 @@ int main (int argc, char **argv)
|
||||
int res, ch;
|
||||
int background, setprio;
|
||||
int totem_log_service;
|
||||
log_init ("MAIN");
|
||||
|
||||
/* default configuration
|
||||
*/
|
||||
@ -420,7 +426,7 @@ int main (int argc, char **argv)
|
||||
|
||||
log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service RELEASE '%s'\n", RELEASE_VERSION);
|
||||
log_printf (LOG_LEVEL_NOTICE, "Copyright (C) 2002-2006 MontaVista Software, Inc and contributors.\n");
|
||||
log_printf (LOG_LEVEL_NOTICE, "Copyright (C) 2006 Red Hat, Inc.\n");
|
||||
log_printf (LOG_LEVEL_NOTICE, "Copyright (C) 2006-2007 Red Hat, Inc.\n");
|
||||
|
||||
signal (SIGINT, sigintr_handler);
|
||||
signal (SIGUSR2, sigusr2_handler);
|
||||
@ -513,11 +519,13 @@ int main (int argc, char **argv)
|
||||
openais_exit_error (AIS_DONE_MAINCONFIGREAD);
|
||||
}
|
||||
|
||||
res = log_setup (&error_string, &main_config);
|
||||
res = logsys_config_file_set (&error_string, main_config.logfile);
|
||||
if (res == -1) {
|
||||
log_printf (LOG_LEVEL_ERROR, error_string);
|
||||
openais_exit_error (AIS_DONE_LOGSETUP);
|
||||
}
|
||||
logsys_config_facility_set ("openais", main_config.syslog_facility);
|
||||
logsys_config_mode_set (main_config.logmode);
|
||||
|
||||
aisexec_uid_determine (&main_config);
|
||||
|
||||
@ -534,20 +542,21 @@ int main (int argc, char **argv)
|
||||
aisexec_mlockall ();
|
||||
|
||||
totem_config.totem_logging_configuration = totem_logging_configuration;
|
||||
totem_log_service = _log_init ("TOTEM");
|
||||
totem_config.totem_logging_configuration.log_level_security = mkpri (LOG_LEVEL_SECURITY, totem_log_service);
|
||||
totem_config.totem_logging_configuration.log_level_error = mkpri (LOG_LEVEL_ERROR, totem_log_service);
|
||||
totem_config.totem_logging_configuration.log_level_warning = mkpri (LOG_LEVEL_WARNING, totem_log_service);
|
||||
totem_config.totem_logging_configuration.log_level_notice = mkpri (LOG_LEVEL_NOTICE, totem_log_service);
|
||||
totem_config.totem_logging_configuration.log_level_debug = mkpri (LOG_LEVEL_DEBUG, totem_log_service);
|
||||
totem_config.totem_logging_configuration.log_printf = internal_log_printf;
|
||||
totem_log_service = _logsys_subsys_create ("TOTEM", LOG_INFO);
|
||||
totem_config.totem_logging_configuration.log_level_security = logsys_mkpri (LOG_LEVEL_SECURITY, totem_log_service);
|
||||
totem_config.totem_logging_configuration.log_level_error = logsys_mkpri (LOG_LEVEL_ERROR, totem_log_service);
|
||||
totem_config.totem_logging_configuration.log_level_warning = logsys_mkpri (LOG_LEVEL_WARNING, totem_log_service);
|
||||
totem_config.totem_logging_configuration.log_level_notice = logsys_mkpri (LOG_LEVEL_NOTICE, totem_log_service);
|
||||
totem_config.totem_logging_configuration.log_level_debug = logsys_mkpri (LOG_LEVEL_DEBUG, totem_log_service);
|
||||
totem_config.totem_logging_configuration.log_printf = logsys_log_printf;
|
||||
|
||||
/*
|
||||
* Sleep for a while to let other nodes in the cluster
|
||||
* understand that this node has been away (if it was
|
||||
* an aisexec restart).
|
||||
*/
|
||||
usleep(totem_config.token_timeout * 2000);
|
||||
|
||||
// TODO what is this hack for? usleep(totem_config.token_timeout * 2000);
|
||||
|
||||
/*
|
||||
* if totempg_initialize doesn't have root priveleges, it cannot
|
||||
|
@ -45,26 +45,30 @@
|
||||
#include "util.h"
|
||||
#include "mainconfig.h"
|
||||
#include "mempool.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "totem.h"
|
||||
#include "service.h"
|
||||
|
||||
static char error_string_response[512];
|
||||
|
||||
/* This just makes the code below a little neater */
|
||||
static inline int objdb_get_string(struct objdb_iface_ver0 *objdb, unsigned int object_service_handle,
|
||||
char *key, char **value)
|
||||
static inline int objdb_get_string (
|
||||
struct objdb_iface_ver0 *objdb,
|
||||
unsigned int object_service_handle,
|
||||
char *key, char **value)
|
||||
{
|
||||
int res;
|
||||
|
||||
*value = NULL;
|
||||
if ( !(res = objdb->object_key_get (object_service_handle,
|
||||
key,
|
||||
strlen (key),
|
||||
(void *)value,
|
||||
NULL))) {
|
||||
if (*value)
|
||||
key,
|
||||
strlen (key),
|
||||
(void *)value,
|
||||
NULL))) {
|
||||
|
||||
if (*value) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -76,31 +80,38 @@ static inline void objdb_get_int (
|
||||
char *value = NULL;
|
||||
|
||||
if (!objdb->object_key_get (object_service_handle,
|
||||
key,
|
||||
strlen (key),
|
||||
(void *)&value,
|
||||
NULL)) {
|
||||
key,
|
||||
strlen (key),
|
||||
(void *)&value,
|
||||
NULL)) {
|
||||
|
||||
if (value) {
|
||||
*intvalue = atoi(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct logsys_config_struct {
|
||||
char subsys[6];
|
||||
unsigned int priority;
|
||||
unsigned int tags;
|
||||
} logsys_logger;
|
||||
|
||||
int openais_main_config_read (
|
||||
struct objdb_iface_ver0 *objdb,
|
||||
char **error_string,
|
||||
struct main_config *main_config)
|
||||
{
|
||||
unsigned int object_service_handle;
|
||||
unsigned int object_logger_handle;
|
||||
unsigned int object_logger_subsys_handle;
|
||||
char *value;
|
||||
char *error_reason = error_string_response;
|
||||
int i;
|
||||
|
||||
memset (main_config, 0, sizeof (struct main_config));
|
||||
|
||||
objdb->object_find_reset (OBJECT_PARENT_HANDLE);
|
||||
|
||||
main_config->logmode = LOG_MODE_FLUSH_AFTER_CONFIG;
|
||||
if (objdb->object_find (
|
||||
OBJECT_PARENT_HANDLE,
|
||||
"logging",
|
||||
@ -109,45 +120,45 @@ int openais_main_config_read (
|
||||
|
||||
if (!objdb_get_string (objdb,object_service_handle, "to_file", &value)) {
|
||||
if (strcmp (value, "yes") == 0) {
|
||||
main_config->logmode |= LOG_MODE_FILE;
|
||||
main_config->logmode |= LOG_MODE_OUTPUT_FILE;
|
||||
} else
|
||||
if (strcmp (value, "no") == 0) {
|
||||
main_config->logmode &= ~LOG_MODE_FILE;
|
||||
main_config->logmode &= ~LOG_MODE_OUTPUT_FILE;
|
||||
}
|
||||
}
|
||||
if (!objdb_get_string (objdb,object_service_handle, "to_syslog", &value)) {
|
||||
if (strcmp (value, "yes") == 0) {
|
||||
main_config->logmode |= LOG_MODE_SYSLOG;
|
||||
main_config->logmode |= LOG_MODE_OUTPUT_SYSLOG_THREADED;
|
||||
} else
|
||||
if (strcmp (value, "no") == 0) {
|
||||
main_config->logmode &= ~LOG_MODE_SYSLOG;
|
||||
main_config->logmode &= ~LOG_MODE_OUTPUT_SYSLOG_THREADED;
|
||||
}
|
||||
}
|
||||
if (!objdb_get_string (objdb,object_service_handle, "to_stderr", &value)) {
|
||||
if (strcmp (value, "yes") == 0) {
|
||||
main_config->logmode |= LOG_MODE_STDERR;
|
||||
main_config->logmode |= LOG_MODE_OUTPUT_STDERR;
|
||||
} else
|
||||
if (strcmp (value, "no") == 0) {
|
||||
main_config->logmode &= ~LOG_MODE_STDERR;
|
||||
main_config->logmode &= ~LOG_MODE_OUTPUT_STDERR;
|
||||
}
|
||||
}
|
||||
|
||||
if (!objdb_get_string (objdb,object_service_handle, "debug", &value)) {
|
||||
if (strcmp (value, "on") == 0) {
|
||||
main_config->logmode |= LOG_MODE_DEBUG;
|
||||
main_config->logmode |= LOG_MODE_DISPLAY_DEBUG;
|
||||
} else
|
||||
if (strcmp (value, "off") == 0) {
|
||||
main_config->logmode &= ~LOG_MODE_DEBUG;
|
||||
main_config->logmode &= ~LOG_MODE_DISPLAY_DEBUG;
|
||||
} else {
|
||||
goto parse_error;
|
||||
}
|
||||
}
|
||||
if (!objdb_get_string (objdb,object_service_handle, "timestamp", &value)) {
|
||||
if (strcmp (value, "on") == 0) {
|
||||
main_config->logmode |= LOG_MODE_TIMESTAMP;
|
||||
main_config->logmode |= LOG_MODE_DISPLAY_TIMESTAMP;
|
||||
} else
|
||||
if (strcmp (value, "off") == 0) {
|
||||
main_config->logmode &= ~LOG_MODE_TIMESTAMP;
|
||||
main_config->logmode &= ~LOG_MODE_DISPLAY_TIMESTAMP;
|
||||
} else {
|
||||
goto parse_error;
|
||||
}
|
||||
@ -158,10 +169,10 @@ int openais_main_config_read (
|
||||
|
||||
if (!objdb_get_string (objdb,object_service_handle, "fileline", &value)) {
|
||||
if (strcmp (value, "on") == 0) {
|
||||
main_config->logmode |= LOG_MODE_FILELINE;
|
||||
main_config->logmode |= LOG_MODE_DISPLAY_FILELINE;
|
||||
} else
|
||||
if (strcmp (value, "off") == 0) {
|
||||
main_config->logmode &= ~LOG_MODE_FILELINE;
|
||||
main_config->logmode &= ~LOG_MODE_DISPLAY_FILELINE;
|
||||
} else {
|
||||
goto parse_error;
|
||||
}
|
||||
@ -200,63 +211,56 @@ int openais_main_config_read (
|
||||
}
|
||||
}
|
||||
|
||||
while ( objdb->object_find (object_service_handle,
|
||||
"logger",
|
||||
strlen ("logger"),
|
||||
&object_logger_handle) == 0) {
|
||||
struct logger_config *logger_tmp;
|
||||
logger_tmp = realloc (main_config->logger,
|
||||
sizeof(struct logger_config) * (main_config->loggers + 1));
|
||||
if (logger_tmp == NULL) {
|
||||
error_reason = "no more memory";
|
||||
goto other_error;
|
||||
}
|
||||
main_config->logger = logger_tmp;
|
||||
i = main_config->loggers;
|
||||
main_config->loggers++;
|
||||
memset(&main_config->logger[i], 0, sizeof(struct logger_config));
|
||||
while (objdb->object_find (object_service_handle,
|
||||
"logger_subsys",
|
||||
strlen ("logger_subsys"),
|
||||
&object_logger_subsys_handle) == 0) {
|
||||
|
||||
if (!objdb_get_string (objdb, object_logger_handle, "ident", &value)) {
|
||||
main_config->logger[i].ident = value;
|
||||
if (!objdb_get_string (objdb,
|
||||
object_logger_subsys_handle,
|
||||
"subsys", &value)) {
|
||||
|
||||
strncpy (logsys_logger.subsys, value,
|
||||
sizeof (logsys_logger.subsys));
|
||||
}
|
||||
else {
|
||||
error_reason = "ident required for logger directive";
|
||||
error_reason = "subsys required for logger directive";
|
||||
goto parse_error;
|
||||
}
|
||||
if (!objdb_get_string (objdb, object_logger_handle, "debug", &value)) {
|
||||
if (!objdb_get_string (objdb, object_logger_subsys_handle, "debug", &value)) {
|
||||
if (strcmp (value, "on") == 0) {
|
||||
main_config->logger[i].level = LOG_LEVEL_DEBUG;
|
||||
logsys_logger.priority = LOG_LEVEL_DEBUG;
|
||||
} else
|
||||
if (strcmp (value, "off") == 0) {
|
||||
main_config->logger[i].level &= ~LOG_LEVEL_DEBUG;
|
||||
logsys_logger.priority &= ~LOG_LEVEL_DEBUG;
|
||||
} else {
|
||||
goto parse_error;
|
||||
}
|
||||
}
|
||||
if (!objdb_get_string (objdb, object_logger_handle, "tags", &value)) {
|
||||
if (!objdb_get_string (objdb, object_logger_subsys_handle, "tags", &value)) {
|
||||
char *token = strtok (value, "|");
|
||||
|
||||
while (token != NULL) {
|
||||
if (strcmp (token, "enter") == 0) {
|
||||
main_config->logger[i].tags |= TAG_ENTER;
|
||||
logsys_logger.tags |= LOGSYS_TAG_ENTER;
|
||||
} else if (strcmp (token, "leave") == 0) {
|
||||
main_config->logger[i].tags |= TAG_LEAVE;
|
||||
logsys_logger.tags |= LOGSYS_TAG_LEAVE;
|
||||
} else if (strcmp (token, "trace1") == 0) {
|
||||
main_config->logger[i].tags |= TAG_TRACE1;
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE1;
|
||||
} else if (strcmp (token, "trace2") == 0) {
|
||||
main_config->logger[i].tags |= TAG_TRACE2;
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE2;
|
||||
} else if (strcmp (token, "trace3") == 0) {
|
||||
main_config->logger[i].tags |= TAG_TRACE3;
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE3;
|
||||
} else if (strcmp (token, "trace4") == 0) {
|
||||
main_config->logger[i].tags |= TAG_TRACE4;
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE4;
|
||||
} else if (strcmp (token, "trace5") == 0) {
|
||||
main_config->logger[i].tags |= TAG_TRACE5;
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE5;
|
||||
} else if (strcmp (token, "trace6") == 0) {
|
||||
main_config->logger[i].tags |= TAG_TRACE6;
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE6;
|
||||
} else if (strcmp (token, "trace7") == 0) {
|
||||
main_config->logger[i].tags |= TAG_TRACE7;
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE7;
|
||||
} else if (strcmp (token, "trace8") == 0) {
|
||||
main_config->logger[i].tags |= TAG_TRACE8;
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE8;
|
||||
} else {
|
||||
error_reason = "bad tags value";
|
||||
goto parse_error;
|
||||
@ -265,6 +269,14 @@ int openais_main_config_read (
|
||||
token = strtok(NULL, "|");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* set individual logger configurations
|
||||
*/
|
||||
logsys_config_subsys_set (
|
||||
logsys_logger.subsys,
|
||||
logsys_logger.tags,
|
||||
logsys_logger.priority);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,24 +302,17 @@ int openais_main_config_read (
|
||||
if (!main_config->group)
|
||||
main_config->group = "ais";
|
||||
|
||||
if ((main_config->logmode & LOG_MODE_FILE) && main_config->logfile == 0) {
|
||||
if ((main_config->logmode & LOG_MODE_OUTPUT_FILE) &&
|
||||
(main_config->logfile == NULL)) {
|
||||
error_reason = "logmode set to 'file' but no logfile specified";
|
||||
goto parse_error;
|
||||
}
|
||||
|
||||
if (!main_config->syslog_facility)
|
||||
if (main_config->syslog_facility == 0)
|
||||
main_config->syslog_facility = LOG_DAEMON;
|
||||
|
||||
return 0;
|
||||
|
||||
other_error:
|
||||
sprintf (error_string_response,
|
||||
"error parsing config: %s.\n",
|
||||
error_reason);
|
||||
|
||||
*error_string = error_string_response;
|
||||
return -1;
|
||||
|
||||
parse_error:
|
||||
sprintf (error_string_response,
|
||||
"parse error in config: %s.\n",
|
||||
|
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2005 MontaVista Software, Inc.
|
||||
* Copyright (c) 2006-2007 Red Hat, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Steven Dake (sdake@mvista.com)
|
||||
* Author: Steven Dake (sdake@redhat.com)
|
||||
*
|
||||
* This software licensed under BSD license, the text of which follows:
|
||||
*
|
||||
@ -31,15 +32,8 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
#include <netinet/in.h>
|
||||
#include "../include/saAis.h"
|
||||
#include "../include/list.h"
|
||||
#include "aispoll.h"
|
||||
#include "totemsrp.h"
|
||||
#include "totempg.h"
|
||||
*/
|
||||
#include "objdb.h"
|
||||
#include "logsys.h"
|
||||
|
||||
#ifndef MAINCONFIG_H_DEFINED
|
||||
#define MAINCONFIG_H_DEFINED
|
||||
@ -55,27 +49,20 @@ struct dynamic_service {
|
||||
};
|
||||
#define MAX_DYNAMIC_SERVICES 128
|
||||
|
||||
struct logger_config {
|
||||
char *ident;
|
||||
int level;
|
||||
int tags;
|
||||
int mode;
|
||||
};
|
||||
|
||||
struct main_config {
|
||||
/*
|
||||
* logging
|
||||
* logging configuration
|
||||
*/
|
||||
int logmode;
|
||||
char *logfile;
|
||||
int syslog_facility;
|
||||
unsigned int logmode;
|
||||
unsigned int syslog_facility;
|
||||
unsigned int minimum_priority;
|
||||
|
||||
/* user/group to run as */
|
||||
/*
|
||||
* user/group to run as
|
||||
*/
|
||||
char *user;
|
||||
char *group;
|
||||
|
||||
int loggers;
|
||||
struct logger_config *logger;
|
||||
};
|
||||
|
||||
extern int openais_main_config_read (
|
||||
|
@ -58,7 +58,9 @@
|
||||
#include "main.h"
|
||||
#include "ipc.h"
|
||||
#include "totempg.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("MSG", LOG_INFO);
|
||||
|
||||
enum msg_exec_message_req_types {
|
||||
MESSAGE_REQ_EXEC_MSG_QUEUEOPEN = 0,
|
||||
@ -670,8 +672,6 @@ static struct queue_group_entry *queue_group_entry_find (
|
||||
|
||||
static int msg_exec_init_fn (struct objdb_iface_ver0 *objdb)
|
||||
{
|
||||
log_init ("MSG");
|
||||
|
||||
/*
|
||||
* Initialize the saved ring ID.
|
||||
*/
|
||||
|
425
exec/print.c
425
exec/print.c
@ -1,425 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2004 MontaVista Software, Inc.
|
||||
* Copyright (c) 2006 Ericsson AB.
|
||||
*
|
||||
* Author: Steven Dake (sdake@redhat.com)
|
||||
* original work, Add worker thread to avoid blocking syslog
|
||||
*
|
||||
* Author: Hans Feldt
|
||||
* Added support for runtime installed loggers, tags tracing,
|
||||
* and file & line printing.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software licensed under BSD license, the text of which follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#if defined(OPENAIS_LINUX)
|
||||
#include <linux/un.h>
|
||||
#endif
|
||||
#if defined(OPENAIS_BSD) || defined(OPENAIS_DARWIN)
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
#include <syslog.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "swab.h"
|
||||
#include "print.h"
|
||||
#include "totemip.h"
|
||||
#include "../include/saAis.h"
|
||||
#include "mainconfig.h"
|
||||
#include "wthread.h"
|
||||
|
||||
static unsigned int logmode = LOG_MODE_BUFFER | LOG_MODE_STDERR | LOG_MODE_SYSLOG;
|
||||
|
||||
static char *logfile = 0;
|
||||
|
||||
static int log_setup_called;
|
||||
|
||||
static pthread_mutex_t log_mode_mutex;
|
||||
|
||||
static struct worker_thread_group log_thread_group;
|
||||
|
||||
static unsigned int dropped_log_entries = 0;
|
||||
|
||||
#ifndef MAX_LOGGERS
|
||||
#define MAX_LOGGERS 32
|
||||
#endif
|
||||
struct logger loggers[MAX_LOGGERS];
|
||||
|
||||
static FILE *log_file_fp = 0;
|
||||
|
||||
struct log_entry {
|
||||
char *file;
|
||||
int line;
|
||||
int level;
|
||||
char str[128];
|
||||
struct log_entry *next;
|
||||
};
|
||||
|
||||
static struct log_entry *head;
|
||||
|
||||
static struct log_entry *tail;
|
||||
|
||||
struct log_data {
|
||||
unsigned int syslog_pos;
|
||||
unsigned int level;
|
||||
char *log_string;
|
||||
};
|
||||
|
||||
static void log_atexit (void);
|
||||
|
||||
static int logger_init (const char *ident, int tags, int level, int mode)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_LOGGERS; i++) {
|
||||
if (strcmp (loggers[i].ident, ident) == 0) {
|
||||
loggers[i].tags |= tags;
|
||||
if (level > loggers[i].level) {
|
||||
loggers[i].level = level;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == MAX_LOGGERS) {
|
||||
for (i = 0; i < MAX_LOGGERS; i++) {
|
||||
if (strcmp (loggers[i].ident, "") == 0) {
|
||||
strncpy (loggers[i].ident, ident, sizeof(loggers[i].ident));
|
||||
loggers[i].tags = tags;
|
||||
loggers[i].level = level;
|
||||
loggers[i].mode = mode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert(i < MAX_LOGGERS);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static void buffered_log_printf (char *file, int line, int level,
|
||||
char *format, va_list ap)
|
||||
{
|
||||
struct log_entry *entry = malloc(sizeof(struct log_entry));
|
||||
|
||||
entry->file = file;
|
||||
entry->line = line;
|
||||
entry->level = level;
|
||||
entry->next = NULL;
|
||||
if (head == NULL) {
|
||||
head = tail = entry;
|
||||
} else {
|
||||
tail->next = entry;
|
||||
tail = entry;
|
||||
}
|
||||
vsnprintf(entry->str, sizeof(entry->str), format, ap);
|
||||
}
|
||||
|
||||
static void log_printf_worker_fn (void *thread_data, void *work_item)
|
||||
{
|
||||
struct log_data *log_data = (struct log_data *)work_item;
|
||||
|
||||
/*
|
||||
* Output the log data
|
||||
*/
|
||||
if (logmode & LOG_MODE_FILE && log_file_fp != 0) {
|
||||
fprintf (log_file_fp, "%s", log_data->log_string);
|
||||
fflush (log_file_fp);
|
||||
}
|
||||
if (logmode & LOG_MODE_STDERR) {
|
||||
fprintf (stderr, "%s", log_data->log_string);
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
if (logmode & LOG_MODE_SYSLOG) {
|
||||
syslog (log_data->level, &log_data->log_string[log_data->syslog_pos]);
|
||||
}
|
||||
free (log_data->log_string);
|
||||
}
|
||||
|
||||
static void _log_printf (char *file, int line,
|
||||
int level, int id,
|
||||
char *format, va_list ap)
|
||||
{
|
||||
char newstring[4096];
|
||||
char log_string[4096];
|
||||
char char_time[512];
|
||||
struct timeval tv;
|
||||
int i = 0;
|
||||
int len;
|
||||
struct log_data log_data;
|
||||
unsigned int res = 0;
|
||||
|
||||
assert (id < MAX_LOGGERS);
|
||||
|
||||
pthread_mutex_lock (&log_mode_mutex);
|
||||
/*
|
||||
** Buffer before log_setup() has been called.
|
||||
*/
|
||||
if (logmode & LOG_MODE_BUFFER) {
|
||||
buffered_log_printf(file, line, level, format, ap);
|
||||
pthread_mutex_unlock (&log_mode_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (((logmode & LOG_MODE_FILE) || (logmode & LOG_MODE_STDERR)) &&
|
||||
(logmode & LOG_MODE_TIMESTAMP)) {
|
||||
gettimeofday (&tv, NULL);
|
||||
strftime (char_time, sizeof (char_time), "%b %e %k:%M:%S",
|
||||
localtime (&tv.tv_sec));
|
||||
i = sprintf (newstring, "%s.%06ld ", char_time, (long)tv.tv_usec);
|
||||
}
|
||||
|
||||
if ((level == LOG_LEVEL_DEBUG) || (logmode & LOG_MODE_FILELINE)) {
|
||||
sprintf (&newstring[i], "[%s:%04u] %s", file, line, format);
|
||||
} else {
|
||||
sprintf (&newstring[i], "[%-5s] %s", loggers[id].ident, format);
|
||||
}
|
||||
if (dropped_log_entries) {
|
||||
/*
|
||||
* Get rid of \n if there is one
|
||||
*/
|
||||
if (newstring[strlen (newstring) - 1] == '\n') {
|
||||
newstring[strlen (newstring) - 1] = '\0';
|
||||
}
|
||||
len = sprintf (log_string,
|
||||
"%s - prior to this log entry, openais logger dropped '%d' messages because of overflow.", newstring, dropped_log_entries + 1);
|
||||
} else {
|
||||
len = vsprintf (log_string, newstring, ap);
|
||||
}
|
||||
|
||||
/*
|
||||
** add line feed if not done yet
|
||||
*/
|
||||
if (log_string[len - 1] != '\n') {
|
||||
log_string[len] = '\n';
|
||||
log_string[len + 1] = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* Create work thread data
|
||||
*/
|
||||
log_data.syslog_pos = i;
|
||||
log_data.level = level;
|
||||
log_data.log_string = strdup (log_string);
|
||||
if (log_data.log_string == NULL) {
|
||||
goto drop_log_msg;
|
||||
}
|
||||
|
||||
if (log_setup_called) {
|
||||
res = worker_thread_group_work_add (&log_thread_group, &log_data);
|
||||
if (res == 0) {
|
||||
dropped_log_entries = 0;
|
||||
} else {
|
||||
dropped_log_entries += 1;
|
||||
}
|
||||
} else {
|
||||
log_printf_worker_fn (NULL, &log_data);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock (&log_mode_mutex);
|
||||
return;
|
||||
|
||||
drop_log_msg:
|
||||
dropped_log_entries++;
|
||||
pthread_mutex_unlock (&log_mode_mutex);
|
||||
}
|
||||
|
||||
int _log_init (const char *ident)
|
||||
{
|
||||
assert (ident != NULL);
|
||||
|
||||
/*
|
||||
** do different things before and after log_setup() has been called
|
||||
*/
|
||||
if (log_setup_called) {
|
||||
return logger_init (ident, TAG_LOG, LOG_LEVEL_INFO, 0);
|
||||
} else {
|
||||
return logger_init (ident, ~0, LOG_LEVEL_DEBUG, 0);
|
||||
}
|
||||
}
|
||||
|
||||
int log_setup (char **error_string, struct main_config *config)
|
||||
{
|
||||
int i;
|
||||
static char error_string_response[512];
|
||||
|
||||
if (config->logmode & LOG_MODE_FILE) {
|
||||
log_file_fp = fopen (config->logfile, "a+");
|
||||
if (log_file_fp == 0) {
|
||||
sprintf (error_string_response,
|
||||
"Can't open logfile '%s' for reason (%s).\n",
|
||||
config->logfile, strerror (errno));
|
||||
*error_string = error_string_response;
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_lock (&log_mode_mutex);
|
||||
logmode = config->logmode;
|
||||
pthread_mutex_unlock (&log_mode_mutex);
|
||||
logfile = config->logfile;
|
||||
|
||||
if (config->logmode & LOG_MODE_SYSLOG) {
|
||||
openlog("openais", LOG_CONS|LOG_PID, config->syslog_facility);
|
||||
}
|
||||
|
||||
/*
|
||||
** reinit all loggers that has initialised before log_setup() was called.
|
||||
*/
|
||||
for (i = 0; i < MAX_LOGGERS; i++) {
|
||||
loggers[i].tags = TAG_LOG;
|
||||
if (config->logmode & LOG_MODE_DEBUG) {
|
||||
loggers[i].level = LOG_LEVEL_DEBUG;
|
||||
} else {
|
||||
loggers[i].level = LOG_LEVEL_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** init all loggers that has configured level and tags
|
||||
*/
|
||||
for (i = 0; i < config->loggers; i++) {
|
||||
if (config->logger[i].level == 0)
|
||||
config->logger[i].level = LOG_LEVEL_INFO;
|
||||
config->logger[i].tags |= TAG_LOG;
|
||||
logger_init (config->logger[i].ident,
|
||||
config->logger[i].tags,
|
||||
config->logger[i].level,
|
||||
config->logger[i].mode);
|
||||
}
|
||||
|
||||
worker_thread_group_init (
|
||||
&log_thread_group,
|
||||
1,
|
||||
1024,
|
||||
sizeof (struct log_data),
|
||||
0,
|
||||
NULL,
|
||||
log_printf_worker_fn);
|
||||
|
||||
|
||||
/*
|
||||
** Flush what we have buffered
|
||||
*/
|
||||
log_flush();
|
||||
|
||||
internal_log_printf(__FILE__, __LINE__, LOG_LEVEL_DEBUG, "log setup\n");
|
||||
|
||||
atexit (log_atexit);
|
||||
|
||||
log_setup_called = 1;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void internal_log_printf (char *file, int line, int priority,
|
||||
char *format, ...)
|
||||
{
|
||||
int id = LOG_ID(priority);
|
||||
int level = LOG_LEVEL(priority);
|
||||
va_list ap;
|
||||
|
||||
assert (id < MAX_LOGGERS);
|
||||
|
||||
if (LOG_LEVEL(priority) > loggers[id].level) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_start (ap, format);
|
||||
_log_printf (file, line, level, id, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void internal_log_printf2 (char *file, int line, int level, int id,
|
||||
char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
assert (id < MAX_LOGGERS);
|
||||
|
||||
va_start (ap, format);
|
||||
_log_printf (file, line, level, id, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void trace (char *file, int line, int tag, int id, char *format, ...)
|
||||
{
|
||||
assert (id < MAX_LOGGERS);
|
||||
|
||||
if (tag & loggers[id].tags) {
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, format);
|
||||
_log_printf (file, line, LOG_LEVEL_DEBUG, id, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
static void log_atexit (void)
|
||||
{
|
||||
if (log_setup_called) {
|
||||
worker_thread_group_wait (&log_thread_group);
|
||||
}
|
||||
}
|
||||
|
||||
void log_flush (void)
|
||||
{
|
||||
if (log_setup_called) {
|
||||
log_setup_called = 0;
|
||||
worker_thread_group_exit (&log_thread_group);
|
||||
worker_thread_group_atsegv (&log_thread_group);
|
||||
} else {
|
||||
struct log_entry *entry = head;
|
||||
struct log_entry *tmp;
|
||||
|
||||
/* do not buffer these printouts */
|
||||
logmode &= ~LOG_MODE_BUFFER;
|
||||
|
||||
while (entry) {
|
||||
internal_log_printf(entry->file, entry->line,
|
||||
entry->level, entry->str);
|
||||
tmp = entry;
|
||||
entry = entry->next;
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
head = tail = NULL;
|
||||
}
|
||||
}
|
211
exec/print.h
211
exec/print.h
@ -1,211 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2004 MontaVista Software, Inc.
|
||||
* Author: Steven Dake (sdake@mvista.com)
|
||||
*
|
||||
* Copyright (c) 2006 Ericsson AB.
|
||||
* Author: Hans Feldt
|
||||
* Description: Added support for runtime installed loggers, tags tracing,
|
||||
* and file & line printing.
|
||||
*
|
||||
* Copyright (c) 2006 Sun Microsystems, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software licensed under BSD license, the text of which follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PRINT_H_DEFINED
|
||||
#define PRINT_H_DEFINED
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#define LOG_MODE_DEBUG 1
|
||||
#define LOG_MODE_TIMESTAMP 2
|
||||
#define LOG_MODE_FILE 4
|
||||
#define LOG_MODE_SYSLOG 8
|
||||
#define LOG_MODE_STDERR 16
|
||||
#define LOG_MODE_FILELINE 32
|
||||
#define LOG_MODE_BUFFER 64
|
||||
|
||||
/*
|
||||
* Log levels, compliant with syslog and SA Forum Log spec.
|
||||
*/
|
||||
#define LOG_LEVEL_EMERG LOG_EMERG
|
||||
#define LOG_LEVEL_ALERT LOG_ALERT
|
||||
#define LOG_LEVEL_CRIT LOG_CRIT
|
||||
#define LOG_LEVEL_ERROR LOG_ERR
|
||||
#define LOG_LEVEL_WARNING LOG_WARNING
|
||||
#define LOG_LEVEL_SECURITY LOG_WARNING // openais specific
|
||||
#define LOG_LEVEL_NOTICE LOG_NOTICE
|
||||
#define LOG_LEVEL_INFO LOG_INFO
|
||||
#define LOG_LEVEL_DEBUG LOG_DEBUG
|
||||
|
||||
/*
|
||||
** Log tags, used by trace macros, uses 32 bits => 32 different tags
|
||||
*/
|
||||
#define TAG_LOG 1<<0
|
||||
#define TAG_ENTER 1<<1
|
||||
#define TAG_LEAVE 1<<2
|
||||
#define TAG_TRACE1 1<<3
|
||||
#define TAG_TRACE2 1<<4
|
||||
#define TAG_TRACE3 1<<5
|
||||
#define TAG_TRACE4 1<<6
|
||||
#define TAG_TRACE5 1<<7
|
||||
#define TAG_TRACE6 1<<8
|
||||
#define TAG_TRACE7 1<<9
|
||||
#define TAG_TRACE8 1<<10
|
||||
|
||||
struct logger {
|
||||
char ident[6];
|
||||
unsigned int level;
|
||||
unsigned int tags;
|
||||
unsigned int mode;
|
||||
};
|
||||
|
||||
extern struct logger loggers[];
|
||||
|
||||
/*
|
||||
** The logger_identifier variable holds the numerical identifier for a logger
|
||||
** obtained with log_init() and hides it from the logger.
|
||||
*/
|
||||
static int logger_identifier __attribute__((unused));
|
||||
|
||||
extern void internal_log_printf (char *file, int line, int priority, char *format, ...) __attribute__((format(printf, 4, 5)));
|
||||
extern void internal_log_printf2 (char *file, int line, int level, int id, char *format, ...) __attribute__((format(printf, 5, 6)));
|
||||
extern void trace (char *file, int line, int tag, int id, char *format, ...) __attribute__((format(printf, 5, 6)));
|
||||
extern void log_flush(void);
|
||||
|
||||
#define LEVELMASK 0x07 /* 3 bits */
|
||||
#define LOG_LEVEL(p) ((p) & LEVELMASK)
|
||||
#define IDMASK (0x3f << 3) /* 6 bits */
|
||||
#define LOG_ID(p) (((p) & IDMASK) >> 3)
|
||||
|
||||
#define _mkpri(lvl, id) (((id) << 3) | (lvl))
|
||||
|
||||
static inline int mkpri (int level, int id)
|
||||
{
|
||||
return _mkpri (level, id);
|
||||
}
|
||||
|
||||
#ifndef main_config
|
||||
struct main_config;
|
||||
#endif
|
||||
extern int log_setup (char **error_string, struct main_config *config);
|
||||
|
||||
extern int _log_init (const char *ident);
|
||||
static inline void log_init (const char *ident)
|
||||
{
|
||||
logger_identifier = _log_init (ident);
|
||||
}
|
||||
|
||||
extern void log_atsegv (void);
|
||||
|
||||
#define log_printf(lvl, format, args...) do { \
|
||||
if ((lvl) <= loggers[logger_identifier].level) { \
|
||||
internal_log_printf2 (__FILE__, __LINE__, lvl, logger_identifier, format, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define dprintf(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
internal_log_printf2 (__FILE__, __LINE__, LOG_LEVEL_DEBUG, logger_identifier, format, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define ENTER_VOID() do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_ENTER, logger_identifier, ">%s\n", __FUNCTION__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define ENTER(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_ENTER, logger_identifier, ">%s: " format, __FUNCTION__, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define LEAVE_VOID() do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_LEAVE, logger_identifier, "<%s\n", __FUNCTION__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define LEAVE(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_LEAVE, logger_identifier, "<%s: " format, __FUNCTION__, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE1(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_TRACE1, logger_identifier, format, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE2(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_TRACE2, logger_identifier, format, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE3(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_TRACE3, logger_identifier, format, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE4(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_TRACE4, logger_identifier, format, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE5(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_TRACE5, logger_identifier, format, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE6(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_TRACE6, logger_identifier, format, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE7(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_TRACE7, logger_identifier, format, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TRACE8(format, args...) do { \
|
||||
if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) { \
|
||||
trace (__FILE__, __LINE__, TAG_TRACE8, logger_identifier, format, ##args); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#endif /* PRINT_H_DEFINED */
|
@ -43,7 +43,9 @@
|
||||
#include "service.h"
|
||||
#include "mainconfig.h"
|
||||
#include "util.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("SERV", LOG_INFO);
|
||||
|
||||
struct default_service {
|
||||
char *name;
|
||||
@ -158,8 +160,6 @@ int openais_service_default_objdb_set (struct objdb_iface_ver0 *objdb)
|
||||
}
|
||||
}
|
||||
|
||||
log_init ("SERV");
|
||||
|
||||
for (i = 0; i < sizeof (default_services) / sizeof (struct default_service); i++) {
|
||||
openais_service_objdb_add (objdb, default_services[i].name, default_services[i].ver);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2005-2006 MontaVista Software, Inc.
|
||||
* Copyright (c) 2006 Ericsson AB.
|
||||
* Copyright (c) 2006-2007 Red Hat, Inc.
|
||||
*
|
||||
* Author: Steven Dake (sdake@mvista.com)
|
||||
* Author: Hans Feldt
|
||||
*
|
||||
@ -58,9 +60,11 @@
|
||||
#include "totem.h"
|
||||
#include "vsf.h"
|
||||
#include "../lcr/lcr_ifact.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "util.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("SYNC", LOG_INFO);
|
||||
|
||||
#define MESSAGE_REQ_SYNC_BARRIER 0
|
||||
#define MESSAGE_REQ_SYNC_REQUEST 1
|
||||
|
||||
@ -290,7 +294,6 @@ int sync_register (
|
||||
void *vsf_iface_p;
|
||||
char openais_vsf_type[1024];
|
||||
|
||||
log_init ("SYNC");
|
||||
res = totempg_groups_initialize (
|
||||
&sync_group_handle,
|
||||
sync_deliver_fn,
|
||||
|
@ -75,7 +75,7 @@
|
||||
#include "config.h"
|
||||
#include "tlist.h"
|
||||
#define LOG_SERVICE LOG_SERVICE_IPC
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
|
||||
#include "util.h"
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include "util.h"
|
||||
#include "totem.h"
|
||||
#include "totemconfig.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "objdb.h"
|
||||
#include "tlist.h" /* for HZ */
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2004 MontaVista Software, Inc.
|
||||
* Copyright (c) 2004 Open Source Development Lab
|
||||
* Copyright (c) 2006-2007 Red Hat, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -41,7 +42,9 @@
|
||||
#include "../include/saAis.h"
|
||||
#include "../include/list.h"
|
||||
#include "util.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("MAIN", LOG_INFO);
|
||||
|
||||
/*
|
||||
* Compare two names. returns non-zero on match.
|
||||
@ -87,8 +90,8 @@ void _openais_exit_error (
|
||||
enum e_ais_done err, const char *file, unsigned int line)
|
||||
{
|
||||
log_printf (LOG_LEVEL_ERROR, "AIS Executive exiting "
|
||||
"with status %d at %s:%u.\n", err, file, line);
|
||||
log_flush();
|
||||
"with status %d at %s:%u.\n", err, file, line);
|
||||
logsys_flush();
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -57,11 +57,13 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "print.h"
|
||||
#include "logsys.h"
|
||||
#include "swab.h"
|
||||
#include "vsf.h"
|
||||
#include "../lcr/lcr_comp.h"
|
||||
|
||||
LOGSYS_DECLARE_SUBSYS ("YKD", LOG_INFO);
|
||||
|
||||
#define YKD_PROCESSOR_COUNT_MAX 32
|
||||
|
||||
enum ykd_header_values {
|
||||
@ -503,8 +505,6 @@ static int ykd_init (
|
||||
int primary_designated,
|
||||
struct memb_ring_id *ring_id))
|
||||
{
|
||||
log_init ("YKD");
|
||||
|
||||
ykd_primary_callback_fn = primary_callback_fn;
|
||||
|
||||
totempg_groups_initialize (
|
||||
|
Loading…
Reference in New Issue
Block a user