Changeset 16822 for trunk/FACT++
- Timestamp:
- 06/13/13 13:26:40 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/showlog.cc
r16817 r16822 2 2 3 3 #include "Time.h" 4 #include "tools.h" 4 5 #include "WindowLog.h" 5 6 #include "Configuration.h" … … 17 18 ("begin,b", var<string>(), "Start time to be displayed (e.g. 20:00:12)") 18 19 ("end,e", var<string>(), "End time to be displayed (e.g. 21:00:13)") 19 ("day,d", var<int16_t>()->implicit_value(true)->default_value(-1), "Index of block between start and end time to be displayed.")20 20 ("verbose,v", var<int16_t>()->implicit_value(true)->default_value(8), "Verbosity level (0:only fatal errors, 8:everything)") 21 21 ("color,c", po_bool(false), "Process a file which already contains color codes") … … 41 41 "Use -c or --color to process color coded files.\n" 42 42 "\n" 43 "The default is to read from stdin.\n" 44 "\n" 45 "Usage: showlog [-c] [-vN] [-b start] [-e end] [-d day] [file1 ...]\n"; 43 "The default is to read from stdin if no filoename as given. If, as " 44 "a filename, just a number between 2000000 and 21000000 is given, " 45 "e.g. 20111016 a log with the name /fact/aux/2011/10/16/20111016.log " 46 "is read.\n" 47 "\n" 48 "Usage: showlog [-c] [-vN] [-b start] [-e end] [file1 ...]\n"; 46 49 cout << endl; 47 50 } … … 61 64 62 65 63 void showlog( const string &fname, const Time &tbeg, const Time &tend, int16_t day, int16_t severity, bool color)66 void showlog(string fname, const Time &tbeg, const Time &tend, int16_t severity, bool color) 64 67 { 65 68 // Alternatives … … 69 72 const boost::regex reg("\x1B\[[0-9;]*[a-zA-Z]"); 70 73 74 const uint32_t night = atoi(fname.c_str()); 75 if (night>20000000 && night<21000000 &&to_string(night)==fname) 76 fname = Tools::Form("/fact/aux/%04d/%02d/%02d/%d.log", 77 night/10000, (night/100)%100, night%100, night); 78 79 if (!fname.empty()) 80 cerr << "Reading " << fname << endl; 81 71 82 ifstream fin(fname.empty() ? "/dev/stdin" : fname.c_str()); 83 if (!fin) 84 throw runtime_error(strerror(errno)); 72 85 73 86 string buffer; … … 93 106 const Time t("1970-01-01 "+tm); 94 107 95 if (day>=0) 108 if (tbeg.IsValid() && !tend.IsValid() && t<tbeg) 109 continue; 110 111 if (tend.IsValid() && !tbeg.IsValid() && t>tend) 112 continue; 113 114 if (tbeg.IsValid() && tend.IsValid()) 96 115 { 97 if (tprev<tbeg && t>tbeg) 98 counter++; 99 100 tprev = t; 101 102 if (day!=counter) 103 continue; 116 if (tend>tbeg) 117 { 118 if (t<tbeg) 119 continue; 120 if (t>tend) 121 continue; 122 } 123 else 124 { 125 if (t>tbeg) 126 continue; 127 if (t<tend) 128 continue; 129 } 104 130 } 105 106 if (tbeg.IsValid() && t<tbeg)107 continue;108 109 if (tend.IsValid() && t>tend)110 continue;111 131 } 112 132 … … 175 195 176 196 if (files.size()==0) 177 showlog("", tbeg, tend, conf.Get<int16_t>(" day"), conf.Get<int16_t>("verbose"), conf.Get<bool>("color"));197 showlog("", tbeg, tend, conf.Get<int16_t>("verbose"), conf.Get<bool>("color")); 178 198 179 199 for (auto it=files.begin(); it!=files.end(); it++) 180 showlog(*it, tbeg, tend, conf.Get<int16_t>(" day"), conf.Get<int16_t>("verbose"), conf.Get<bool>("color"));200 showlog(*it, tbeg, tend, conf.Get<int16_t>("verbose"), conf.Get<bool>("color")); 181 201 182 202 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.