Ignore:
Timestamp:
08/30/04 11:45:51 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/showlog.cc

    r4756 r4800  
    11#include <errno.h>
    22#include <fstream>
     3
     4#include <TRegexp.h>
    35
    46#include "MArgs.h"
     
    1618    gLog << " or" << endl;
    1719    gLog << "   showlog [options] < filename" << endl << endl;
     20    gLog.Usage();
    1821    gLog << "   -?, -h, --help            This help" << endl << endl;
    1922    gLog << endl;
     
    2427    gLog << " colored output with less use the option -R, eg." << endl;
    2528    gLog << "   less -R logfile.log" << endl << endl;
     29}
     30
     31void RemoveAnsi(TString &s)
     32{
     33    static const TRegexp regexp("[][[][0-9]+[m]");
     34
     35    int i=0;
     36
     37    while (1)
     38    {
     39        Ssiz_t len = 0;
     40        Ssiz_t idx = s.Index(regexp, &len);
     41        if (idx<0)
     42            break;
     43
     44        s.Remove(idx, len);
     45    }
    2646}
    2747
     
    3757        return -1;
    3858    }
     59
     60    const Bool_t kNoColors = arg.HasOnly("--no-colors") || arg.HasOnly("-a");
     61
     62    gLog.Setup(arg);
    3963
    4064    if (arg.GetNumOptions()>0)
     
    6993            break;
    7094
    71         s.ReplaceAll("", "\033");
     95        if (kNoColors)
     96            RemoveAnsi(s);
     97        else
     98            s.ReplaceAll("", "\033");
    7299        gLog << s << endl;
    73100    }
Note: See TracChangeset for help on using the changeset viewer.