6 from systemd
import journal
8 urllib3
.disable_warnings()
9 http
= urllib3
.PoolManager()
11 webhook_url
= "<%= @slack_logger %>"
12 webhook_icon
= "https://git.immae.eu/releases/logger.png"
14 def send_to_discord(message
):
15 def send_chunk(chunk
):
17 "avatar_url": webhook_icon
,
19 "content": "```\n{}\n```".format(chunk
),
21 encoded
= json
.dumps(data
).encode('utf-8')
23 r
= http
.request("POST", webhook_url
,
24 headers
={'Content-Type': 'application/json'}
,
27 b
= json
.loads(r
.data
)
28 time
.sleep(b
["retry_after"] / 900)
29 r
= http
.request("POST", webhook_url
,
30 headers
={'Content-Type': 'application/json'}
,
35 for line
in message
.split("\n"):
36 if len(line
) + len(chunk
) > 2000 - 17:
44 j
.add_match(_SYSTEMD_UNIT
="cryptoportfolio-app.service")
49 lines
= [entry
["MESSAGE"] for entry
in list(j
)]
51 send_to_discord("\n".join(lines
))