source: trunk/MagicSoft/Mars/showlog.cc@ 4754

Last change on this file since 4754 was 4732, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 1.1 KB
Line 
1#include <errno.h>
2#include <fstream>
3
4#include "MLog.h"
5
6using namespace std;
7
8static void Usage()
9{
10 gLog << endl;
11 gLog << "Sorry the usage is:" << endl;
12 gLog << " showlog filename" << endl;
13 gLog << " or" << endl;
14 gLog << " showlog < filename" << endl << endl;
15 gLog << " This program converts colored output made with ansi codes" << endl;
16 gLog << " (like it is done by MLog) and redirected into a file back" << endl;
17 gLog << " into colored output." << endl << endl;
18}
19
20// FIXME: Enhance this tool with a converter to HTMl, etc.
21// Add option for 'no-colors'
22int main(int argc, char **argv)
23{
24 if (argc>2)
25 {
26 Usage();
27 return -1;
28 }
29
30 // casts necessary for gcc 2.95.3
31 istream *in = argc==2 ? (istream*)new ifstream(argv[1]) : (istream*)&cin;
32 if (!*in)
33 {
34 gLog << "Cannot open file " << argv[1] << ": " << strerror(errno) << endl;
35 return -1;
36 }
37
38 TString s;
39 while (1)
40 {
41 s.ReadLine(*in);
42 if (!*in)
43 break;
44
45 s.ReplaceAll("", "\033");
46 gLog << s << endl;
47 }
48
49 if (in!=&cin)
50 delete in;
51
52 return 0;
53}
Note: See TracBrowser for help on using the repository browser.