• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • Directories
  • File List
  • Globals

dprint.c

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * debug print 
00005  *
00006  *
00007  * Copyright (C) 2001-2003 FhG Fokus
00008  *
00009  * This file is part of ser, a free SIP server.
00010  *
00011  * ser is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version
00015  *
00016  * For a license to use the ser software under conditions
00017  * other than those described here, or to purchase support for this
00018  * software, please contact iptel.org by e-mail at the following addresses:
00019  *    info@iptel.org
00020  *
00021  * ser is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  * GNU General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU General Public License 
00027  * along with this program; if not, write to the Free Software 
00028  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029  */
00039 #include "globals.h"
00040 #include "dprint.h"
00041  
00042 #include <stdarg.h>
00043 #include <stdio.h>
00044 #include <strings.h>
00045 
00046 #ifndef NO_SIG_DEBUG
00047 /* signal protection: !=0 when LOG/DBG/... are printing */
00048 volatile int dprint_crit = 0; 
00049 #endif
00050 
00051 static char* str_fac[]={"LOG_AUTH","LOG_CRON","LOG_DAEMON",
00052                         "LOG_KERN","LOG_LOCAL0","LOG_LOCAL1",
00053                         "LOG_LOCAL2","LOG_LOCAL3","LOG_LOCAL4","LOG_LOCAL5",
00054                         "LOG_LOCAL6","LOG_LOCAL7","LOG_LPR","LOG_MAIL",
00055                         "LOG_NEWS","LOG_USER","LOG_UUCP",
00056 #ifndef __OS_solaris
00057                         "LOG_AUTHPRIV","LOG_FTP","LOG_SYSLOG",
00058 #endif
00059                         0};
00060                         
00061 static int int_fac[]={LOG_AUTH ,  LOG_CRON , LOG_DAEMON ,
00062                       LOG_KERN , LOG_LOCAL0 , LOG_LOCAL1 ,
00063                       LOG_LOCAL2 , LOG_LOCAL3 , LOG_LOCAL4 , LOG_LOCAL5 ,
00064                       LOG_LOCAL6 , LOG_LOCAL7 , LOG_LPR , LOG_MAIL ,
00065                       LOG_NEWS , LOG_USER , LOG_UUCP,
00066 #ifndef __OS_solaris
00067                       LOG_AUTHPRIV,LOG_FTP,LOG_SYSLOG,
00068 #endif
00069                       0};
00070 
00071 struct log_level_info log_level_info[] = {
00072         {"ALERT", LOG_ALERT},     /* L_ALERT */
00073         {"BUG", LOG_CRIT},        /* L_BUG */
00074         {"CRITICAL", LOG_CRIT},   /* L_CRIT2 */
00075         {"",    LOG_CRIT},         /* L_CRIT */
00076         {"ERROR", LOG_ERR},       /* L_ERR */
00077         {"WARNING", LOG_WARNING}, /* L_WARN */
00078         {"NOTICE", LOG_NOTICE},   /* L_NOTICE */
00079         {"INFO", LOG_INFO},       /* L_INFO */
00080         {"DEBUG", LOG_DEBUG}      /* L_DBG */
00081 };
00082 
00083 int str2facility(char *s)
00084 {
00085         int i;
00086 
00087         for( i=0; str_fac[i] ; i++) {
00088                 if (!strcasecmp(s,str_fac[i]))
00089                         return int_fac[i];
00090         }
00091         return -1;
00092 }
00093 
00094 /* fixup function for log_facility cfg parameter */
00095 int log_facility_fixup(void *handle, str *gname, str *name, void **val)
00096 {
00097         int     i;
00098 
00099         if ((i = str2facility((char *)*val)) == -1) {
00100                 LOG(L_ERR, "log_facility_fixup: invalid log facility: %s\n",
00101                         (char *)*val);
00102                 return -1;
00103         }
00104         *val = (void *)(long)i;
00105         return 0;
00106 }
00107 
00108 
00113 /* value for unset local log level  */
00114 #define UNSET_LOCAL_DEBUG_LEVEL -255
00115 
00116 /* the local debug log level */
00117 static int _local_debug_level = UNSET_LOCAL_DEBUG_LEVEL;
00118 
00123 int get_debug_level(void) {
00124         return (_local_debug_level != UNSET_LOCAL_DEBUG_LEVEL) ?
00125                                 _local_debug_level : cfg_get(core, core_cfg, debug);
00126 }
00127 
00131 void set_local_debug_level(int level)
00132 {
00133         _local_debug_level = level;
00134 }
00135 
00139 void reset_local_debug_level(void)
00140 {
00141         _local_debug_level = UNSET_LOCAL_DEBUG_LEVEL;
00142 }

Generated on Tue May 22 2012 13:10:06 for SIP Router by  doxygen 1.7.1