first parameter of log methods is now name

This commit is contained in:
Pavol Rusnak 2016-04-29 21:46:34 +02:00
parent e7bfb64502
commit 4eb87b2fd8
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 11 additions and 10 deletions

View File

@ -17,9 +17,12 @@ build_unix: update ## build unix port (32-bit)
build_unix64: update ## build unix port (64-bit)
make -C vendor/micropython/unix
run_unix: ## run unix port
run: ## run unix port
cd src ; ../vendor/micropython/unix/micropython
emu: ## run emulator
./emu.sh
clean: clean_stmhal clean_unix ## clean all builds
clean_stmhal: ## clean stmhal build

View File

@ -19,27 +19,25 @@ _leveldict = {
level = NOTSET
color = True
def _log(mlevel, msg, *args):
global level
if mlevel >= level:
name = 'name'
def _log(name, mlevel, msg, *args):
if __debug__ and mlevel >= level:
if color:
fmt = '%d \x1b[35m%s\x1b[0m %s \x1b[' + _leveldict[mlevel][1] + 'm' + msg + '\x1b[0m'
else:
fmt = '%d %s %s ' + msg
print(fmt % ((utime.ticks_us(), name, _leveldict[mlevel][0]) + args), file=sys.stderr)
def debug(msg, *args):
def debug(name, msg, *args):
_log(DEBUG, msg, *args)
def info(msg, *args):
def info(name, msg, *args):
_log(INFO, msg, *args)
def warning(msg, *args):
def warning(name, msg, *args):
_log(WARNING, msg, *args)
def error(msg, *args):
def error(name, msg, *args):
_log(ERROR, msg, *args)
def critical(msg, *args):
def critical(name, msg, *args):
_log(CRITICAL, msg, *args)