Ignore:
Timestamp:
03/08/2007 00:29:31 (5 years ago)
Author:
chris
Message:

Convert most printf() and fprintf() calls to use logging framework
instead. (merges [1789])

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/chris/general/bin/bbackupquery/bbackupquery.cpp

    r1690 r1790  
    1313        #include <unistd.h> 
    1414#endif 
     15 
     16#include <errno.h> 
    1517#include <stdio.h> 
    16 #include <sys/types.h> 
     18 
     19#ifdef HAVE_SYS_TYPES_H 
     20        #include <sys/types.h> 
     21#endif 
     22 
    1723#ifdef HAVE_LIBREADLINE 
    1824        #ifdef HAVE_READLINE_READLINE_H 
     
    169175                        if(logFile == 0) 
    170176                        { 
    171                                 printf("Can't open log file '%s'\n", optarg); 
     177                                BOX_ERROR("Failed to open log file '" << 
     178                                        optarg << "': " << strerror(errno)); 
    172179                        } 
    173180                        break; 
     
    202209                if (!SetConsoleCP(CP_UTF8)) 
    203210                { 
    204                         fprintf(stderr, "Failed to set input codepage: " 
    205                                 "error %d\n", GetLastError()); 
     211                        BOX_ERROR("Failed to set input codepage: " << 
     212                                GetErrorMessage(GetLastError())); 
    206213                } 
    207214 
    208215                if (!SetConsoleOutputCP(CP_UTF8)) 
    209216                { 
    210                         fprintf(stderr, "Failed to set output codepage: " 
    211                                 "error %d\n", GetLastError()); 
     217                        BOX_ERROR("Failed to set output codepage: " << 
     218                                GetErrorMessage(GetLastError())); 
    212219                } 
    213220 
     
    223230 
    224231        // Read in the configuration file 
    225         if(!quiet) printf("Using configuration file %s\n",  
    226                 configFilename.c_str()); 
     232        if(!quiet) BOX_INFO("Using configuration file " << configFilename); 
    227233 
    228234        std::string errs; 
     
    233239        if(config.get() == 0 || !errs.empty()) 
    234240        { 
    235                 printf("Invalid configuration file:\n%s", errs.c_str()); 
     241                BOX_FATAL("Invalid configuration file: " << errs); 
    236242                return 1; 
    237243        } 
     
    253259 
    254260        // 2. Connect to server 
    255         if(!quiet) printf("Connecting to store...\n"); 
     261        if(!quiet) BOX_INFO("Connecting to store..."); 
    256262        SocketStreamTLS socket; 
    257263        socket.Open(tlsContext, Socket::TypeINET, conf.GetKeyValue("StoreHostname").c_str(), BOX_PORT_BBSTORED); 
    258264         
    259265        // 3. Make a protocol, and handshake 
    260         if(!quiet) printf("Handshake with store...\n"); 
     266        if(!quiet) BOX_INFO("Handshake with store..."); 
    261267        BackupProtocolClient connection(socket); 
    262268        connection.Handshake(); 
     
    269275         
    270276        // 4. Log in to server 
    271         if(!quiet) printf("Login to store...\n"); 
     277        if(!quiet) BOX_INFO("Login to store..."); 
    272278        // Check the version of the server 
    273279        { 
     
    346352         
    347353        // Done... stop nicely 
    348         if(!quiet) printf("Logging off...\n"); 
     354        if(!quiet) BOX_INFO("Logging off..."); 
    349355        connection.QueryFinished(); 
    350         if(!quiet) printf("Session finished.\n"); 
     356        if(!quiet) BOX_INFO("Session finished."); 
    351357         
    352358        // Return code 
Note: See TracChangeset for help on using the changeset viewer.