Created
August 5, 2016 19:47
-
-
Save brizandrew/42137fe5071f8f27450d55f4e9a3ba9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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