1 // Utility to traverse and simplify verbose log files.
3 // The goal is to take a collection of log files and extract details
4 // related to connections, objects, and invocations to separate out
5 // perhaps multiple processes, or at least threads to get a sense of
6 // invocation lifecycle.
8 // Ideally a collection of files could be used so that invocations
9 // that traverse many processes could be tracked.
11 #include "ace/OS_NS_stdio.h"
12 #include "ace/Log_Msg.h"
13 #include "ace/streams.h"
14 #include "ace/OS_NS_strings.h"
15 #include "ace/Tokenizer_T.h"
17 #include "Invocation.h"
18 #include "PeerObject.h"
19 #include "PeerProcess.h"
23 ACE_TCHAR
*outfile
= 0;
26 parse_filename (Session
&session
, char * buffer
)
29 if (ACE_OS::strchr(buffer
,'=') == 0)
31 log
.process_file (ACE_TEXT_CHAR_TO_TCHAR(buffer
));
35 ACE_Tokenizer_T
<char> tokens(buffer
);
36 tokens
.delimiter_replace('=', 0);
37 char *alias
= tokens
.next();
38 ACE_TString filename
= ACE_TEXT_CHAR_TO_TCHAR(tokens
.next());
39 log
.process_file (filename
.c_str(), alias
);
44 parse_manifest (Session
&session
, ACE_TCHAR
*filename
)
46 // get list of logs, aliases, and other config from file
47 ifstream
strm (ACE_TEXT_ALWAYS_CHAR (filename
));
50 ACE_DEBUG ((LM_DEBUG
,"cannot open manifest file %C\n", filename
));
56 strm
.getline(buffer
,500);
57 if (buffer
[0] == '\0' ||
66 if (session
.has_dir())
69 "supply either output file "
70 "or directory but not both\n"));
73 session
.outfile (buffer
+3);
78 if (session
.has_outfile())
81 "supply either output file "
82 "or directory but not both\n"));
87 session
.make_dir (buffer
+4, true);
91 session
.make_dir (buffer
+3, false);
97 Session::set_tao_version (ACE_TEXT_CHAR_TO_TCHAR (buffer
+ 3));
100 if (buffer
[1] == 'a')
102 session
.alternate_address(buffer
+3);
105 if (buffer
[1] == 'p')
107 session
.default_service (buffer
+3);
111 parse_filename (session
, buffer
);
118 ACE_DEBUG ((LM_DEBUG
, "tao_logWalker recongizes the following arguments\n"));
119 ACE_DEBUG ((LM_DEBUG
, "-o <filename> - write all output to specified file\n"));
120 ACE_DEBUG ((LM_DEBUG
, "-d[d] <directory> - create separate output files, one per log, and put them in specified directory.\n Either -o or -d may be set but not both. Default output to stdout.\n Use -dd to further split thread and peer process details onto multiple files."));
121 ACE_DEBUG ((LM_DEBUG
, "-m <manifest> - Take inputs from named manifest file\n"));
122 ACE_DEBUG ((LM_DEBUG
, "-t <1.5 .. 2.0> - set source TAO version, default 2.0\n"));
123 ACE_DEBUG ((LM_DEBUG
, "-a <name=address> - bind an alias to a host address.\n Repeat as many times as necessary.\n"));
124 ACE_DEBUG ((LM_DEBUG
, "-p <service=address> - bind a service such as Naming to a specific peer endpoint address\n"));
125 ACE_DEBUG ((LM_DEBUG
, "[alias=]filename - provide a source file with an altenate name"));
129 ACE_TMAIN (int argc
, ACE_TCHAR
**argv
)
133 ACE_ERROR ((LM_ERROR
,
134 " At least one log file must be specified\n"));
138 for (int i
= 1; i
< argc
; i
++)
140 if (ACE_OS::strcasecmp (argv
[i
], ACE_TEXT("-o")) == 0)
142 if (session
.has_dir())
143 ACE_ERROR_RETURN ((LM_ERROR
,
144 "supply either output file "
145 "or directory but not both\n"), 0);
146 session
.outfile(ACE_TEXT_ALWAYS_CHAR(argv
[++i
]));
149 if (ACE_OS::strcasecmp (argv
[i
], ACE_TEXT("-d")) == 0 ||
150 ACE_OS::strcasecmp (argv
[i
], ACE_TEXT("-dd")) == 0)
152 if (session
.has_outfile())
153 ACE_ERROR_RETURN ((LM_ERROR
,
154 "supply either output file "
155 "or directory but not both\n"), 0);
156 bool split
= ACE_OS::strcasecmp (argv
[i
], ACE_TEXT("-dd")) == 0;
157 session
.make_dir (ACE_TEXT_ALWAYS_CHAR(argv
[++i
]), split
);
160 if (ACE_OS::strcasecmp (argv
[i
], ACE_TEXT("-m")) == 0)
162 parse_manifest (session
, argv
[++i
]);
165 if (ACE_OS::strcasecmp (argv
[i
], ACE_TEXT("-t")) == 0)
167 if (Session::set_tao_version (argv
[++i
]))
170 ACE_ERROR_RETURN ((LM_ERROR
,
171 ACE_TEXT("TAO version must be 1.5, 1.6, 1.7, 1.8, or 2.0 \n")), 0);
173 if (ACE_OS::strcasecmp (argv
[i
], ACE_TEXT("-a")) == 0)
175 session
.alternate_address (ACE_TEXT_ALWAYS_CHAR (argv
[++i
]));
178 if (ACE_OS::strcasecmp (argv
[i
], ACE_TEXT("-p")) == 0)
180 session
.default_service (ACE_TEXT_ALWAYS_CHAR (argv
[++i
]));
183 if (argv
[i
][0] == ACE_TEXT('-'))
191 parse_filename (session
, ACE_TEXT_ALWAYS_CHAR (argv
[i
]));