Added sys_adminlog() system for info the appliance admins really
authorJeremy Allison <jra@samba.org>
Wed, 27 Mar 2002 23:17:50 +0000 (23:17 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 27 Mar 2002 23:17:50 +0000 (23:17 +0000)
need to know about. Different from the DEBUG system.
Jeremy.
(This used to be commit 74eac41c681f92a6da0ae2167f031e021862e0d8)

source3/include/includes.h
source3/lib/system.c
source3/param/loadparm.c

index 3bb7d13f7f491010fdd1c0fee6231fa3f8818f55..e19961b57578ae625607c0b283d679b9f2a9437f 100644 (file)
@@ -1049,6 +1049,39 @@ int vasprintf(char **ptr, const char *format, va_list ap);
 #define S_IXOTH 00001           /* execute permission: other */
 #endif
 
+/* For sys_adminlog(). */
+#ifndef LOG_EMERG
+#define LOG_EMERG       0       /* system is unusable */
+#endif
+
+#ifndef LOG_ALERT
+#define LOG_ALERT       1       /* action must be taken immediately */
+#endif
+
+#ifndef LOG_CRIT
+#define LOG_CRIT        2       /* critical conditions */
+#endif
+
+#ifndef LOG_ERR
+#define LOG_ERR         3       /* error conditions */
+#endif
+
+#ifndef LOG_WARNING
+#define LOG_WARNING     4       /* warning conditions */
+#endif
+
+#ifndef LOG_NOTICE
+#define LOG_NOTICE      5       /* normal but significant condition */
+#endif
+
+#ifndef LOG_INFO
+#define LOG_INFO        6       /* informational */
+#endif
+
+#ifndef LOG_DEBUG
+#define LOG_DEBUG       7       /* debug-level messages */
+#endif
+
 /* NetBSD doesn't have these */
 #ifndef SHM_R
 #define SHM_R 0400
index 2a0889b3569cd257bf36ad1a7205d6bc8b2118a7..8c7eec939ea10228d3db9bff2000373a8678fa42 100644 (file)
@@ -1204,3 +1204,31 @@ const char *sys_dlerror(void)
        return NULL;
 #endif
 }
+
+/**************************************************************************
+ Wrapper for Admin Logs.
+****************************************************************************/
+
+void sys_adminlog(int priority, const char *format_str, ...)
+{
+       va_list ap;
+       int ret;
+       char **msgbuf = NULL;
+
+       if (!lp_admin_log())
+               return;
+
+       va_start( ap, format_str );
+       ret = vasprintf( msgbuf, format_str, ap );
+       va_end( ap );
+
+       if (ret == -1)
+               return;
+
+#if defined(HAVE_SYSLOG)
+       syslog( priority, "%s", *msgbuf );
+#else
+       DEBUG(0,("%s", *msgbuf ));
+#endif
+       SAFE_FREE(*msgbuf);
+}
index 6144fea63bc3010e04515856590c8082dd8310a8..af9ec06d950a91c973d42e56172b7320d2f34928 100644 (file)
@@ -247,6 +247,7 @@ typedef struct
        BOOL bReadPrediction;
        BOOL bReadbmpx;
        BOOL bSyslogOnly;
+       BOOL bAdminLog;
        BOOL bBrowseList;
        BOOL bNISHomeMap;
        BOOL bTimeServer;
@@ -793,6 +794,8 @@ static struct parm_struct parm_table[] = {
 #endif /* WITH_SSL */
 
        {"Logging Options", P_SEP, P_SEPARATOR},
+
+       {"admin log", P_BOOL, P_GLOBAL, &Globals.bAdminLog, NULL, NULL, 0},
        {"log level", P_INTEGER, P_GLOBAL, &DEBUGLEVEL_CLASS[DBGC_ALL], handle_debug_list, NULL, 0},
        {"debuglevel", P_INTEGER, P_GLOBAL, &DEBUGLEVEL_CLASS[DBGC_ALL], handle_debug_list, NULL, 0},
        {"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL, NULL, 0},
@@ -1285,6 +1288,7 @@ static void init_globals(void)
        Globals.bStripDot = False;
        Globals.syslog = 1;
        Globals.bSyslogOnly = False;
+       Globals.bAdminLog = False;
        Globals.bTimestampLogs = True;
        Globals.bDebugHiresTimestamp = False;
        Globals.bDebugPid = False;
@@ -1607,6 +1611,7 @@ FN_GLOBAL_BOOL(lp_strip_dot, &Globals.bStripDot)
 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
+FN_GLOBAL_BOOL(lp_admin_log, &Globals.bAdminLog)
 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)