#include <time.h> #ifndef NONAMESPACE #include <iostream> using namespace std; #else #include <iostream.h> #endif #include <string> #include "timestamp.h" #include "outputtype.h" #define DEFUSAGE false #define DEFOUTPUT OUTPUT_STANDARD #define DEFLOGFILE "log" #define DEFBEGIN "1990/01/01 00:00:00" #define DEFEND "2029/12/31 23:59:59" int ParseArgs( int argc, char **argv, bool *usage, int *outputtype, time_t *begints, time_t *endts, string *p4logfile ) { string name; string value; int iscan; int rc; *usage = DEFUSAGE; *outputtype = DEFOUTPUT; str2time( DEFBEGIN, begints ); str2time( DEFEND, endts ); *p4logfile = DEFLOGFILE; argc--; argv++; while( argc ) { name = *argv; if( ( iscan = name.find( "=" ) ) != name.npos ) { value = name.substr( iscan + 1 ); name.erase( iscan ); } else { value.erase(); } if( name == "--help" || name == "-h" ) { *usage = true; } else if( name == "--detail" ) { *outputtype = OUTPUT_DETAIL; } else if( name == "--csv" ) { *outputtype = OUTPUT_CSV; } else if( name == "--begin" ) { if( !value.empty() ) if( rc = str2time( value, begints ) ) { cout << "Invalid begin time!\n"; return rc; } } else if( name == "--end" ) { if( !value.empty() ) if( rc = str2time( value, endts ) ) { cout << "Invalid end time!\n"; return rc; } } else { *p4logfile = *argv; } argc--; argv++; } return 0; } int PrintArgs( int outputtype, time_t begints, time_t endts, string p4logfile ) { string tsstr; // Print no headers in CSV mode if ( outputtype != OUTPUT_CSV ) { cout << "Output Format: "; if( outputtype == OUTPUT_STANDARD ) cout << "Standard\n"; else if ( outputtype == OUTPUT_DETAIL ) cout << "Detail\n"; time2str( begints, &tsstr ); cout << "Begin time: " << tsstr << "\n"; time2str( endts, &tsstr ); cout << "End time: " << tsstr << "\n"; cout << "p4d server log: " << p4logfile << "\n"; } return 0; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 5390 | Shawn Hladky |
modified p4loga: added --csv switch to output a coma-separated variable file identifying every command function recorded. No header or summary info is displayed. This file can be loaded in a spreadsheet application or imported into a database for further analysis. added support to identify the ClientProgram name from the log file. At this point, only server logs for a 2005.1 server have been (minimally) tested. |
||
#1 | 5389 | Shawn Hladky | Branching p4loga for modifications | ||
//guest/michael_shields/src/p4loga/args.cc | |||||
#2 | 1722 | Michael Shields |
p4loga builds for freebsd4 (play), hpux11 (hell), linux24x86 (duey), and solaris26 (shucks). A bit of porting was required for the hpux11 build (aCC as configured on hell isn't quite up to speed with respect to namespaces). |
||
#1 | 1610 | Michael Shields |
Adding p4d log analyzer concocted by myself. Compiles and executes on Red Hat 6.0, 7.0, and probably a few other operating systems with perhaps a little help. Still needs comments. |