def get_app_logs_json(): ''' Return a JSON stream with the kano logs ''' # Fetch the kano logs kano_logs = logging.read_logs() # Transform them into a sorted, indented json stream kano_logs_json = json.dumps(kano_logs, sort_keys=True, indent=4, separators=(',', ': ')) return kano_logs_json
def get_app_logs_raw(): ''' Extract kano logs in raw format: "LOGFILE: component" (one line per component) followed by entries in the form: "2014-09-30T10:18:54.532015 kano-updater info: Return value: 0" ''' logs = logging.read_logs() output = "" for f, data in logs.iteritems(): app_name = os.path.basename(f).split(".")[0] output += "LOGFILE: {}\n".format(f) for line in data: line["time"] = datetime.datetime.fromtimestamp(line["time"]).isoformat() output += "{time} {app} {level}: {message}\n".format(app=app_name, **line) return output
def get_data_from_log_file(self): self.data_from_log = klm.read_logs() self.assertIn(self.exp_log_fname_full, self.data_from_log, msg='No log file was found for this app')