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

Last change on this file since 4711 was 4591, 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 istream *in = argc==2 ? new ifstream(argv[1]) : &cin;
31 if (!*in)
32 {
33 gLog << "Cannot open file " << argv[1] << ": " << strerror(errno) << endl;
34 return -1;
35 }
36
37 TString s;
38 while (1)
39 {
40 s.ReadLine(*in);
41 if (!*in)
42 break;
43
44 s.ReplaceAll("", "\033");
45 gLog << s << endl;
46 }
47
48 if (in!=&cin)
49 delete in;
50
51 return 0;
52}
Note: See TracBrowser for help on using the repository browser.