def handle(self, *args, **options): if options.get('output') not in self.generate_output_functions: print "Invalid output format, valid choices are {0}".format(self.generate_output_functions.keys()) exit(2) LOGFILE = options.get('file') try: raw_data, errors = analyze_log_file(LOGFILE, PATTERN, reverse_paths=options.get('reverse'), progress=options.get('progress')) except IOError: print "File not found" exit(2) if options.get('showerrors'): if errors: print "Error reading the following lines:" for error in errors: print "line %d: %s" % (error['line_number'], error['line_content']) else: print "No errors reading the log file" data = add_stats_to(raw_data) generate_output_fn = self.generate_output_functions[options.get('output')] print generate_output_fn(data)
def handle(self, *args, **options): if options.get('output') not in self.generate_output_functions: print "Invalid output format, valid choices are {0}".format( self.generate_output_functions.keys()) exit(2) LOGFILE = options.get('file') try: raw_data, errors = analyze_log_file( LOGFILE, PATTERN, reverse_paths=options.get('reverse'), progress=options.get('progress')) except IOError: print "File not found" exit(2) if options.get('showerrors'): if errors: print "Error reading the following lines:" for error in errors: print "line %d: %s" % (error['line_number'], error['line_content']) else: print "No errors reading the log file" data = add_stats_to(raw_data) generate_output_fn = self.generate_output_functions[options.get( 'output')] print generate_output_fn(data)
def handle(self, *args, **options): # --date-from YY-MM-DD # specify a date filter start # default to first date in file # --date-to YY-MM-DD # specify a date filter end # default to now LOGFILE = options.get('file') try: data = analyze_log_file(LOGFILE, PATTERN, reverse_paths=options.get('reverse')) except IOError: print "File not found" exit(2) print generate_table_from(data)
def handle(self, *args, **options): if options.get('output') not in self.generate_output_functions: print "Invalid output format, valid choices are {0}".format(generate_output_functions.keys()) exit(2) LOGFILE = options.get('file') try: raw_data = analyze_log_file(LOGFILE, PATTERN, reverse_paths=options.get('reverse'), progress=options.get('progress')) except IOError: print "File not found" exit(2) data = add_stats_to(raw_data) generate_output_fn = self.generate_output_functions[options.get('output')] print generate_output_fn(data)