Ignore:
Timestamp:
30/11/2008 22:25:27 (3 years ago)
Author:
chris
Message:

Add support for using the logging framework to log (most) bbackupquery
output to a file, with its own verbosity level.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupquery/bbackupquery.cpp

    r2285 r2393  
    6363        "[-u] " 
    6464#endif 
    65         "\n\t[-c config_file] [-l log_file] [commands]\n" 
     65        "\n" 
     66        "\t[-c config_file] [-o log_file] [-O log_file_level]\n" 
     67        "\t[-l protocol_log_file] [commands]\n" 
     68        "\n" 
    6669        "As many commands as you require.\n" 
    6770        "If commands are multiple words, remember to enclose the command in quotes.\n" 
    68         "Remember to use quit command if you don't want to drop into interactive mode.\n"); 
     71        "Remember to use the quit command unless you want to end up in interactive mode.\n"); 
    6972        exit(1); 
    7073} 
     
    119122 
    120123#ifdef WIN32 
    121         const char* validOpts = "qvwuc:l:W:"; 
     124        const char* validOpts = "qvwuc:l:o:O:W:"; 
    122125        bool unicodeConsole = false; 
    123126#else 
    124         const char* validOpts = "qvwc:l:W:"; 
    125 #endif 
     127        const char* validOpts = "qvwc:l:o:O:W:"; 
     128#endif 
     129 
     130        std::string fileLogFile; 
     131        Log::Level fileLogLevel = Log::INVALID; 
    126132 
    127133        // See if there's another entry on the command line 
     
    188194                        break; 
    189195 
     196                case 'o': 
     197                        fileLogFile = optarg; 
     198                        fileLogLevel = Log::EVERYTHING; 
     199                        break; 
     200 
     201                case 'O': 
     202                        { 
     203                                fileLogLevel = Logging::GetNamedLevel(optarg); 
     204                                if (fileLogLevel == Log::INVALID) 
     205                                { 
     206                                        BOX_FATAL("Invalid logging level"); 
     207                                        return 2; 
     208                                } 
     209                        } 
     210                        break; 
     211 
    190212#ifdef WIN32 
    191213                case 'u': 
     
    204226         
    205227        Logging::SetGlobalLevel((Log::Level)masterLevel); 
     228 
     229        std::auto_ptr<FileLogger> fileLogger; 
     230        if (fileLogLevel != Log::INVALID) 
     231        { 
     232                fileLogger.reset(new FileLogger(fileLogFile, fileLogLevel)); 
     233        } 
    206234 
    207235        bool quiet = false; 
Note: See TracChangeset for help on using the changeset viewer.