Skip to content

Instantly share code, notes, and snippets.

@aczzdx
Created March 7, 2019 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aczzdx/875d42fa21bd214909f9d98a1250b5c4 to your computer and use it in GitHub Desktop.
Save aczzdx/875d42fa21bd214909f9d98a1250b5c4 to your computer and use it in GitHub Desktop.
Simple logger for sending updates to Slack using incoming webhook
#!/usr/bin/env python3
# Change the following url as the webhook requested from the Slack App
SLACK_WEBHOOK = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
import requests
def slack_msg(text):
return requests.post(SLACK_MSG_HOOK, json={"text":text})
# a sample to send
epoch = 1
loss = 1234.567891
acc = 0.9874245
slack_msg("[Epoch {}]\tloss:{:.4f}\tacc:{:.4f}".format(epoch, loss, acc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment