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): 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)