Implemented log.exception, improved logging

Removed unused code
This commit is contained in:
slush0 2016-04-30 01:48:13 +02:00 committed by Pavol Rusnak
parent b0d9a4b884
commit 3a7e343a43
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 8 additions and 10 deletions

View File

@ -2,7 +2,7 @@ import sys
import utime
from . import utils
import log
from . import log
_new_layout = None
_current_layout = None

View File

@ -1,3 +1,4 @@
import _io
import sys
import utime
@ -39,5 +40,10 @@ def warning(name, msg, *args):
def error(name, msg, *args):
_log(name, ERROR, msg, *args)
def exception(name, exc):
out = _io.StringIO()
sys.print_exception(exc, out)
_log(name, ERROR, out.getvalue())
def critical(name, msg, *args):
_log(name, CRITICAL, msg, *args)

View File

@ -1,5 +1,4 @@
import utime
import sys
from uheapq import heappop, heappush
from .utils import type_gen
@ -12,8 +11,6 @@ EVT_TMOVE = const(-2)
EVT_TEND = const(-3)
EVT_MSG = const(-4)
DO_NOTHING = const(-5)
evt_handlers = { EVT_TSTART: None,
EVT_TMOVE: None,
EVT_TEND: None,
@ -114,18 +111,13 @@ def run_forever(start_gens):
# gen ended, forget it and go on
continue
except Exception as e:
# FIXME
log.error(__name__, str(e))
sys.print_exception(e)
# log.exception(__name__, e)
log.exception(__name__, e)
continue
if isinstance(ret, int):
if ret >= 0:
# sleep until ret, call us later
__call_at(ret, gen)
elif ret == DO_NOTHING:
print("Removing gen from time queue")
else:
# wait for event
raise NotImplementedError()