Changeset 3628 for branches


Ignore:
Timestamp:
Dec 21, 2016, 3:18:07 PM (3 years ago)
Author:
bruno
Message:

Change mr_msg_init interface definition to include argc and argv, which allows to detect the presence of the -K option and setup the log level accordingly as early as possible

Location:
branches/3.3/mondo/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/common/libmondo-cli.c

    r3610 r3628  
    976976                    if (optarg[0] != '/' && optarg[len - 1] == '/') {
    977977                        optarg[--len] = '\0';
    978                         log_to_screen
    979                             ("Warning - param '%s' should not have trailing slash!",
    980                              optarg);
     978                        log_to_screen("Warning - param '%s' should not have trailing slash!", optarg);
    981979                    }
    982980                    if (opt == 'd') {
  • branches/3.3/mondo/src/include/mr_msg.h

    r3509 r3628  
    1717
    1818#define mr_msg(lvl,fmt,args...) {mr_msg_int(lvl,__LINE__,__FILE__,__FUNCTION__,fmt,## args);}
    19 extern void mr_msg_init(const char *logfile, int loglevel);
     19extern void mr_msg_init(const char *logfile, int loglevel, int argc, char *argv[]);
    2020extern void mr_msg_close(void);
    2121extern void mr_msg_loglevel(int loglevel);
  • branches/3.3/mondo/src/lib/mr_msg.c

    r3509 r3628  
    1313#define _GNU_SOURCE
    1414#endif
     15
    1516#include <stdio.h>
    1617#include <stdarg.h>
    1718#include <stdlib.h>
     19#include <unistd.h>
     20#include <string.h>
    1821
    1922static int mr_loglevel = 0;
     
    4851
    4952/* Initialization function for messages */
    50 void mr_msg_init(const char *logfile, int loglevel) {
     53void mr_msg_init(const char *logfile, int loglevel, int argc, char *argv[]) {
     54
     55    int i=1;
     56
    5157    if (asprintf(&mr_logfile, "%s", logfile) == -1) {
    5258        fprintf(stderr,"Unable to alloc memory\n");
     
    6773            fprintf(stderr,"Logging desactivated\n");
    6874            mr_msg_close();
     75        }
     76    }
     77    while (i < argc) {
     78        if (strcmp(argv[i],"-K") == 0) {
     79            i++;
     80            if (argv[i]) {
     81                loglevel = atoi(argv[i]);
     82            } else {
     83                fprintf(stderr,"-K option requires a loglevel\n");
     84                mr_msg_close();
     85                exit(-1);
     86            }
    6987        }
    7088    }
  • branches/3.3/mondo/src/mondoarchive/mondoarchive.c

    r3527 r3628  
    324324
    325325    /*  setup log level for new log system as well */
    326     mr_msg_init(MONDO_LOGFILE,g_loglevel);
     326    mr_msg_init(MONDO_LOGFILE,g_loglevel, argc, argv);
    327327
    328328    if (pre_param_configuration()) {
  • branches/3.3/mondo/src/mondorestore/mondorestore.c

    r3613 r3628  
    27972797
    27982798    /*  setup log level for new log system as well */
    2799     mr_msg_init(MONDO_LOGFILE,g_loglevel);
     2799    mr_msg_init(MONDO_LOGFILE,g_loglevel,argc,argv);
    28002800
    28012801    // Handle params here first
Note: See TracChangeset for help on using the changeset viewer.