Navigation


Changeset 899:40d5e8002b12 in freeDiameter for freeDiameterd


Ignore:
Timestamp:
Dec 4, 2012, 5:53:16 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Disable all logs by default, activate required logs by command-line switch. To be improved when file logging is supported

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameterd/main.c

    r740 r899  
    4949static char *conffile = NULL;
    5050static int gnutls_debug = 0;
     51static int fd_msg_log_enabled = 0; /* all logs disabled by default, this field is a bitfield of enabled FD_MSG_LOG_* */
    5152
    5253/* gnutls debug */
     
    8586                gnutls_global_set_log_level (gnutls_debug);
    8687                TRACE_DEBUG(INFO, "Enabled GNUTLS debug at level %d", gnutls_debug);
     88        }
     89       
     90        /* set messages logging */
     91        if (fd_msg_log_enabled) {
     92                if (fd_msg_log_enabled & (1 << FD_MSG_LOG_DROPPED)) {
     93                        CHECK_FCT( fd_msg_log_config(FD_MSG_LOG_DROPPED, FD_MSG_LOGTO_DEBUGONLY, NULL) );
     94                }
     95                if (fd_msg_log_enabled & (1 << FD_MSG_LOG_RECEIVED)) {
     96                        CHECK_FCT( fd_msg_log_config(FD_MSG_LOG_RECEIVED, FD_MSG_LOGTO_DEBUGONLY, NULL) );
     97                }
     98                if (fd_msg_log_enabled & (1 << FD_MSG_LOG_SENT)) {
     99                        CHECK_FCT( fd_msg_log_config(FD_MSG_LOG_SENT, FD_MSG_LOGTO_DEBUGONLY, NULL) );
     100                }
     101                if (fd_msg_log_enabled & (1 << FD_MSG_LOG_NODELIVER)) {
     102                        CHECK_FCT( fd_msg_log_config(FD_MSG_LOG_NODELIVER, FD_MSG_LOGTO_DEBUGONLY, NULL) );
     103                }
     104                if (fd_msg_log_enabled & (1 << FD_MSG_LOG_TIMING)) {
     105                        CHECK_FCT( fd_msg_log_config(FD_MSG_LOG_TIMING, FD_MSG_LOGTO_DEBUGONLY, NULL) );
     106                }
    87107        }
    88108               
     
    149169                "  -V, --version          Print version and exit\n"
    150170                "  -c, --config=filename  Read configuration from this file instead of the \n"
    151                 "                           default location (" DEFAULT_CONF_PATH "/" FD_DEFAULT_CONF_FILENAME ").\n");
     171                "                           default location (" DEFAULT_CONF_PATH "/" FD_DEFAULT_CONF_FILENAME ").\n"
     172                "  -M, --enable_msg_log=( DROPPED | RECEIVED | SENT | NODELIVER | TIMING )\n"
     173                "                         Disable logging of these messages in the output.\n");
    152174        printf( "\nDebug:\n"
    153175                "  These options are mostly useful for developers\n"
     
    175197                { "dbg_file",   required_argument,      NULL, 'F' },
    176198                { "dbg_gnutls", required_argument,      NULL, 'g' },
     199                { "enable_msg_log",     optional_argument,      NULL, 'M' },
    177200                { NULL,         0,                      NULL, 0 }
    178201        };
     
    180203        /* Loop on arguments */
    181204        while (1) {
    182                 c = getopt_long (argc, argv, "hVc:dql:", long_options, &option_index);
     205                c = getopt_long (argc, argv, "hVc:dql:M:", long_options, &option_index);
    183206                if (c == -1)
    184207                        break;  /* Exit from the loop.  */
     
    208231                                }
    209232                                break;
     233                               
     234                        case 'M':       /* disable logging of these messages */
     235                                if (optarg) {
     236                                        if (!strcmp(optarg, "DROPPED")) {
     237                                                fd_msg_log_enabled |= 1 << FD_MSG_LOG_DROPPED;
     238                                        } else
     239                                        if (!strcmp(optarg, "RECEIVED")) {
     240                                                fd_msg_log_enabled |= 1 << FD_MSG_LOG_RECEIVED;
     241                                        } else
     242                                        if (!strcmp(optarg, "SENT")) {
     243                                                fd_msg_log_enabled |= 1 << FD_MSG_LOG_SENT;
     244                                        } else
     245                                        if (!strcmp(optarg, "NODELIVER")) {
     246                                                fd_msg_log_enabled |= 1 << FD_MSG_LOG_NODELIVER;
     247                                        } else
     248                                        if (!strcmp(optarg, "TIMING")) {
     249                                                fd_msg_log_enabled |= 1 << FD_MSG_LOG_TIMING;
     250                                        } else {
     251                                                main_help();
     252                                                exit(0);
     253                                        }
     254                                } else {
     255                                        fd_msg_log_enabled = -1; /* all logs enabled */
     256                                }
    210257
    211258                        case 'd':       /* Increase verbosity of debug messages.  */
Note: See TracChangeset for help on using the changeset viewer.