From edce30ea209312253266ac242661af4dbb6286ea Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 18 Apr 2018 12:50:20 -0500 Subject: [PATCH] added timestamp to logger & removed debug prints --- onionr/api.py | 2 -- onionr/logger.py | 11 +++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/onionr/api.py b/onionr/api.py index f39604dd..cd5b6065 100755 --- a/onionr/api.py +++ b/onionr/api.py @@ -226,11 +226,9 @@ class API: host = self.host if hostType == 'private': if not request.host.startswith('127') and not self._utils.checkIsIP(request.host): - print("WHAT") abort(403) elif hostType == 'public': if not request.host.endswith('onion') and not request.host.endswith('i2p'): - print("WHAT2") abort(403) # Validate x-requested-with, to protect against CSRF/metadata leaks if not self._developmentMode: diff --git a/onionr/logger.py b/onionr/logger.py index 12b61702..389d868c 100644 --- a/onionr/logger.py +++ b/onionr/logger.py @@ -18,7 +18,7 @@ along with this program. If not, see . ''' -import re, sys +import re, sys, time class colors: ''' @@ -134,15 +134,18 @@ def raw(data): with open(_outputfile, "a+") as f: f.write(colors.filter(data) + '\n') -def log(prefix, data, color = ''): +def log(prefix, data, color = '', timestamp=True): ''' Logs the data prefix : The prefix to the output data : The actual data to output color : The color to output before the data ''' - - output = colors.reset + str(color) + '[' + colors.bold + str(prefix) + colors.reset + str(color) + '] ' + str(data) + colors.reset + if timestamp: + curTime = time.strftime("%m-%d %H:%M:%S") + else: + curTime = '' + output = colors.reset + str(color) + '[' + colors.bold + str(prefix) + colors.reset + str(color) + '] ' + curTime + ' ' + str(data) + colors.reset if not get_settings() & USE_ANSI: output = colors.filter(output)