Python: Fix indentation, hold onto logger
Vicki Pfau vi@endrift.com
Fri, 16 Jun 2017 20:51:42 -0700
1 files changed,
22 insertions(+),
18 deletions(-)
jump to
M
src/platform/python/mgba/log.py
→
src/platform/python/mgba/log.py
@@ -8,29 +8,33 @@ from . import createCallback
createCallback("mLoggerPy", "log", "_pyLog") +defaultLogger = None + def installDefault(logger): - lib.mLogSetDefaultLogger(logger._native) + global defaultLogger + defaultLogger = logger + lib.mLogSetDefaultLogger(logger._native) class Logger(object): - FATAL = lib.mLOG_FATAL - DEBUG = lib.mLOG_DEBUG - INFO = lib.mLOG_INFO - WARN = lib.mLOG_WARN - ERROR = lib.mLOG_ERROR - STUB = lib.mLOG_STUB - GAME_ERROR = lib.mLOG_GAME_ERROR + FATAL = lib.mLOG_FATAL + DEBUG = lib.mLOG_DEBUG + INFO = lib.mLOG_INFO + WARN = lib.mLOG_WARN + ERROR = lib.mLOG_ERROR + STUB = lib.mLOG_STUB + GAME_ERROR = lib.mLOG_GAME_ERROR - def __init__(self): - self._handle = ffi.new_handle(self) - self._native = ffi.gc(lib.mLoggerPythonCreate(self._handle), lib.free) + def __init__(self): + self._handle = ffi.new_handle(self) + self._native = ffi.gc(lib.mLoggerPythonCreate(self._handle), lib.free) - @staticmethod - def categoryName(category): - return ffi.string(lib.mLogCategoryName(category)).decode('UTF-8') + @staticmethod + def categoryName(category): + return ffi.string(lib.mLogCategoryName(category)).decode('UTF-8') - def log(self, category, level, message): - print("{}: {}".format(self.categoryName(category), message)) + def log(self, category, level, message): + print("{}: {}".format(self.categoryName(category), message)) class NullLogger(Logger): - def log(self, category, level, message): - pass + def log(self, category, level, message): + pass