Ignore:
Timestamp:
31/01/2008 23:52:08 (4 years ago)
Author:
chris
Message:

Add support for verbosity control in tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/infrastructure/buildenv-testmain-template.cpp

    r2013 r2082  
    161161 
    162162#ifdef HAVE_GETOPT_H 
     163        #ifdef NDEBUG 
     164        int logLevel = Log::NOTICE; // need an int to do math with 
     165        #else 
     166        int logLevel = Log::INFO; // need an int to do math with 
     167        #endif 
     168 
    163169        struct option longopts[] =  
    164170        { 
     
    171177        int ch; 
    172178         
    173         while ((ch = getopt_long(argc, argv, "c:d:s:t:TUV", longopts, NULL)) 
     179        while ((ch = getopt_long(argc, argv, "c:d:qs:t:vTUV", longopts, NULL)) 
    174180                != -1) 
    175181        { 
     
    203209                        break; 
    204210 
     211                        case 'q': 
     212                        { 
     213                                if(logLevel == Log::NOTHING) 
     214                                { 
     215                                        BOX_FATAL("Too many '-q': " 
     216                                                "Cannot reduce logging " 
     217                                                "level any more"); 
     218                                        return 2; 
     219                                } 
     220                                logLevel--; 
     221                        } 
     222                        break; 
     223 
     224                        case 'v': 
     225                        { 
     226                                if(logLevel == Log::EVERYTHING) 
     227                                { 
     228                                        BOX_FATAL("Too many '-v': " 
     229                                                "Cannot increase logging " 
     230                                                "level any more"); 
     231                                        return 2; 
     232                                } 
     233                                logLevel++; 
     234                        } 
     235                        break; 
     236 
     237                        case 'V': 
     238                        { 
     239                                logLevel = Log::EVERYTHING; 
     240                        } 
     241                        break; 
     242 
    205243                        case 't': 
    206244                        { 
     
    219257                                Console::SetShowTime(true); 
    220258                                Console::SetShowTimeMicros(true); 
    221                         } 
    222                         break; 
    223  
    224                         case 'V': 
    225                         { 
    226                                 Logging::SetGlobalLevel(Log::EVERYTHING); 
    227259                        } 
    228260                        break; 
     
    243275                } 
    244276        } 
     277 
     278        Logging::SetGlobalLevel((Log::Level)logLevel); 
    245279 
    246280        argc -= optind - 1; 
Note: See TracChangeset for help on using the changeset viewer.