1
2
mirror of https://github.com/vimagick/dockerfiles synced 2024-06-24 07:48:38 +00:00
dockerfiles/mysql-proxy/code.py
2016-05-09 23:30:22 +08:00

21 lines
433 B
Python
Executable File

#!/usr/bin/env python3
import select from systemd
import journal
j = journal.Reader()
j.log_level(journal.LOG_INFO)
j.add_match(CONTAINER_NAME="mysql-proxy")
j.seek_tail()
j.get_previous()
p = select.poll()
p.register(j, j.get_events())
while p.poll():
if j.process() != journal.APPEND:
continue
for entry in j:
if entry['MESSAGE']:
print(str(entry['__REALTIME_TIMESTAMP']), entry['MESSAGE'])