Created
December 3, 2016 18:33
-
-
Save adarshdec23/c57c7667f2ccd60b3ff593daf4ab3730 to your computer and use it in GitHub Desktop.
A python method to write logs to the console.
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 | |
def ConsoleWrite(messageType, message, variable = None): | |
print datetime.now().strftime('%Y-%m-%d %H:%M:%S'), | |
print "[" + messageType + "]\t", | |
if variable: | |
print type(variable).__name__, ":", message | |
print(variable) | |
else: | |
print message | |
ConsoleWrite("INFO", "Program staring...") | |
ConsoleWrite("WARNING", "Some warning") | |
a = { | |
"hello":"world", | |
"numbers":[ | |
1, | |
2, | |
3] | |
} | |
ConsoleWrite("DEBUG", "a", a) | |
ConsoleWrite("INFO", "Program terminating...") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment