from rmsdump import *

def read_log_entry (log_entry):
  return tuple(log_entry.val[i].val for i in range(0, 3))

def print_log (log_atom):
  print '%s> %s: %s' % (log_atom[0].strftime('%Y-%m-%d %H:%M:%S'), log_atom[1], log_atom[2])

if __name__ == "__main__":
  data = sys.stdin.read()
  stream = DataStream(data)
  (rmses, num_rms, err) = extract_rms(stream)

  log_rmses = [rms for rms in rmses if rms['name'].startswith('LOG_') and rms['name'] != 'LOG_IX']
  log_entries = []
  for log_rms in log_rmses:
    log_entries.extend([rec['content'][1] for rec in log_rms['records']])

  log_digest = [read_log_entry(le) for le in log_entries]
  for la in sorted(log_digest, key=lambda la: la[0]):
    print_log(la)

add script to read device logs from rms dump