Add error logging

master
Arinerron 2018-04-18 18:57:37 -07:00
parent 86a2c0d6d0
commit ded179bcad
No known key found for this signature in database
GPG Key ID: 99383627861C62F0
2 changed files with 17 additions and 12 deletions

View File

@ -216,9 +216,11 @@ def warn(data, timestamp=True):
log('!', data, colors.fg.orange, timestamp=timestamp)
# error: when only one function, module, or process of the program encountered a problem and must stop
def error(data, timestamp=True):
def error(data, error=None, timestamp=True):
if get_level() <= LEVEL_ERROR:
log('-', data, colors.fg.red, timestamp=timestamp)
if not error is None:
debug('Error details: ' + str(error))
# fatal: when the something so bad has happened that the prorgam must stop
def fatal(data, timestamp=True):

View File

@ -291,6 +291,7 @@ class OnionrUtils:
for i in blocks:
if len (i) == 0:
continue
try:
with open('data/blocks/' + i + '.dat', 'r') as potentialMessage:
message = potentialMessage.read()
if message.startswith('-pm-'):
@ -302,4 +303,6 @@ class OnionrUtils:
pass
else:
logger.info('Recieved message: ' + message.decode())
except Exception as error:
logger.error('Failed to open block ' + str(i) + '.', error=error)
return