From 06eeb3c45803bcf26ee586103a974fd852de21b9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 12 Sep 2000 00:47:11 +0000 Subject: much nicer message interface. We now register dispatch functions, allowing new bits of code or vfs modules to register functions without impacting on the messaging code itself. Also note that multiple registrations for the same message type are possible allowing the same message to be delivered to multiple parts of the code (possibly useful for reload messages). (This used to be commit c3350c77f52cade48d2945574e09cb630af85b92) --- source3/lib/debug.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'source3/lib/debug.c') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 5279dda2e3..e67aea7fd3 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -122,7 +122,7 @@ static size_t format_pos = 0; /**************************************************************************** receive a "set debug level" message ****************************************************************************/ -void debug_message(pid_t src, void *buf, int len) +void debug_message(enum message_type msg_type, pid_t src, void *buf, size_t len) { int level; memcpy(&level, buf, sizeof(int)); @@ -143,28 +143,27 @@ void debug_message_send(pid_t pid, int level) * get ready for syslog stuff * ************************************************************************** ** */ -void setup_logging( char *pname, BOOL interactive ) - { - if( interactive ) - { - stdout_logging = True; - dbf = stdout; - } -#ifdef WITH_SYSLOG - else - { - char *p = strrchr( pname,'/' ); +void setup_logging(char *pname, BOOL interactive) +{ + message_register(MSG_DEBUG, debug_message); - if( p ) - pname = p + 1; + if (interactive) { + stdout_logging = True; + dbf = stdout; + } +#ifdef WITH_SYSLOG + else { + char *p = strrchr( pname,'/' ); + if (p) + pname = p + 1; #ifdef LOG_DAEMON - openlog( pname, LOG_PID, SYSLOG_FACILITY ); + openlog( pname, LOG_PID, SYSLOG_FACILITY ); #else /* for old systems that have no facility codes. */ - openlog( pname, LOG_PID ); + openlog( pname, LOG_PID ); #endif - } + } #endif - } /* setup_logging */ +} /* setup_logging */ /* ************************************************************************** ** * reopen the log files -- cgit