Changeset 16968 for trunk/FACT++
- Timestamp:
- 07/20/13 14:38:16 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/showlog.cc
r16884 r16968 19 19 ("end,e", var<string>(), "End time to be displayed (e.g. 21:00:13)") 20 20 ("verbose,v", var<int16_t>()->implicit_value(true)->default_value(8), "Verbosity level (0:only fatal errors, 8:everything)") 21 ("color,c", po_bool(false), "Process a file which already contains color codes") 21 ("color,c", po_switch(), "Process a file which already contains color codes") 22 ("strip,s", po_switch(), "Strip color codes completely") 22 23 ; 23 24 … … 65 66 66 67 67 void showlog(string fname, const Time &tbeg, const Time &tend, int16_t severity, bool color )68 void showlog(string fname, const Time &tbeg, const Time &tend, int16_t severity, bool color, bool strip) 68 69 { 69 70 // Alternatives … … 71 72 // \x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K] 72 73 // \x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K] 73 const boost::regex reg("\x1B\[ [0-9;]*[a-zA-Z]");74 const boost::regex reg("\x1B\[([0-9]{1,3}(;[0-9]{1,3})?[a-zA-Z]"); 74 75 75 76 const uint32_t night = atoi(fname.c_str()); … … 93 94 while (getline(fin, buffer, '\n')) 94 95 { 95 if (color )96 if (color || strip) 96 97 buffer = boost::regex_replace(buffer, reg, ""); 97 98 … … 130 131 } 131 132 132 if (buffer.size()>1 )133 if (buffer.size()>1 && !strip) 133 134 { 134 135 int16_t lvl = -1; … … 161 162 } 162 163 163 log<< buffer << endl;164 (strip?cout:log) << buffer << endl; 164 165 } 165 166 } … … 194 195 195 196 if (files.size()==0) 196 showlog("", tbeg, tend, conf.Get<int16_t>("verbose"), conf.Get<bool>("color") );197 showlog("", tbeg, tend, conf.Get<int16_t>("verbose"), conf.Get<bool>("color"), conf.Get<bool>("strip")); 197 198 198 199 for (auto it=files.begin(); it!=files.end(); it++) 199 showlog(*it, tbeg, tend, conf.Get<int16_t>("verbose"), conf.Get<bool>("color") );200 showlog(*it, tbeg, tend, conf.Get<int16_t>("verbose"), conf.Get<bool>("color"), conf.Get<bool>("strip")); 200 201 201 202 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.