Skip to content

Instantly share code, notes, and snippets.

@takeouchida
Created June 25, 2015 02:22
Show Gist options
  • Save takeouchida/cd70b1ca11ce43457a72 to your computer and use it in GitHub Desktop.
Save takeouchida/cd70b1ca11ce43457a72 to your computer and use it in GitHub Desktop.
A way to log
import os
import traceback
# Write a message to /var/log/hoge.log
os.system("echo `date '+%Y/%m/%d %H:%M:%S.%N'` 'Some message' >> /var/log/hoge.log")
# Write a traceback to /var/log/hoge.log
os.system("echo `date '+%Y/%m/%d %H:%M:%S.%N'` '" + traceback.format_exc() + "' >> /var/log/hoge.log")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment