Skip to content

Instantly share code, notes, and snippets.

@solomon081
Created March 29, 2012 22:11
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 solomon081/2244264 to your computer and use it in GitHub Desktop.
Save solomon081/2244264 to your computer and use it in GitHub Desktop.
DateTime Error Log
def logtime(message, logfile):
"""Writes a message to a log file, as well as the time"""
log = open(logfile, 'a')
log.write("Error at:")
log.write(str(datetime.datetime.now()))
log.write(message)
def relog(message, logfile):
"""Overwrites the log file and writes a message to the log file, as well as the time"""
log = open(logfile, 'w')
log.write(str(datetime.datetime.now()))
log.write(message)
def readlog(message, logfile):
"""Reads the log file"""
log = open(logfile, 'r')
log.readlines()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment