Logo Search packages:      
Sourcecode: rapple version File versions  Download package

static void open_logfile (  )  [static]

Opens the log file (if not already open) reporting errors to stderr.

Definition at line 38 of file logger.c.

References rpl_cfg_get_logfile(), rpl_cfg_get_loglevel(), rpl_me_free(), and rpl_message_get().

Referenced by log_msg(), and rpl_log_fl_msg().

               {
    rpl_str_t msg, logfile;
    /* only perform open if necessary */
    if(lp == NULL) {
        rpl_str_t lf = rpl_cfg_get_logfile();
            if(lf == NULL)
            {
                  fprintf(stderr, "%s\n", "Error! No logfile defined! See configuration file.\n");
                  exit(-1);
            }
        logfile = (strcmp(lf,RPL_STR_NUL) == 0) ? RPL_DEFAULT_LOGFILE : lf;
        errno = 0;
        if((lp = fopen(logfile, "a")) == NULL) {
            msg = rpl_message_get("LOGFILE_NOT_FOUND", RPL_EOM);
            fprintf(stderr, "Fatal: %s: %s (%s)\n", msg, logfile, strerror(errno));
            exit(EXIT_FAILURE);
        }
        llevel = rpl_cfg_get_loglevel();
        rpl_me_free (lf);
    }
}


Generated by  Doxygen 1.6.0   Back to index