Created
June 23, 2017 13:34
-
-
Save Bakterija/184c791c13d0b49caaa7e8e0e131cf9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.logger import Logger | |
from kivy.properties import ListProperty | |
from kivy.event import EventDispatcher | |
from time import time | |
class LoggerHistoryProper(EventDispatcher): | |
data = ListProperty() | |
def __init__(self, **kwargs): | |
self.register_event_type('on_add_data') | |
super(self.__class__, self).__init__(**kwargs) | |
def on_add_data(self, data): | |
pass | |
def add_data(self, text, level): | |
new = {'time': time(), 'level': level, 'text': text} | |
self.data.append(new) | |
self.dispatch('on_add_data', new) | |
LoggerHistoryProper = LoggerHistoryProper() | |
def exception(msg, *args): | |
Logger._info(msg) | |
LoggerHistoryProper.add_data(msg, 'exception') | |
def warning(msg, *args): | |
Logger._info(msg) | |
LoggerHistoryProper.add_data(msg, 'warning') | |
def error(msg, *args): | |
Logger._info(msg) | |
LoggerHistoryProper.add_data(msg, 'error') | |
def info(msg, *args): | |
Logger._info(msg) | |
LoggerHistoryProper.add_data(msg, 'info') | |
Logger._exception = Logger.exception | |
Logger._warning = Logger.warning | |
Logger._info = Logger.error | |
Logger._info = Logger.info | |
Logger.exception = exception | |
Logger.warning = warning | |
Logger.info = error | |
Logger.info = info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment