Skip to content

Instantly share code, notes, and snippets.

@brizandrew
Created August 5, 2016 19:47
Show Gist options
  • Save brizandrew/42137fe5071f8f27450d55f4e9a3ba9f to your computer and use it in GitHub Desktop.
Save brizandrew/42137fe5071f8f27450d55f4e9a3ba9f to your computer and use it in GitHub Desktop.
from datetime import datetime
"""
@function updateLog
Adds a line to the .log file with a timestamp
@param {str} text: The line to add
@kwarg {int} [level]: The intendenation level of the line, default=0
"""
def updateLog(text, **kwargs):
if 'level' in kwargs:
level = kwargs['level']
else:
level = 0;
with open('.log', 'a') as log_file:
curTime = datetime.now().strftime('(%m/%d/%y %H:%M:%S) ')
log_file.write(('\t'*level) + curTime + text + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment