Skip to content

Instantly share code, notes, and snippets.

@Bakterija
Created June 25, 2017 16:09
Show Gist options
  • Save Bakterija/f681466f75487c1647fee8a7e26e5977 to your computer and use it in GitHub Desktop.
Save Bakterija/f681466f75487c1647fee8a7e26e5977 to your computer and use it in GitHub Desktop.
from kivy.properties import ListProperty
from kivy.event import EventDispatcher
from kivy.logger import Logger
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._exception(msg)
LoggerHistoryProper.add_data(msg, 'exception')
def warning(msg, *args):
Logger._warning(msg)
LoggerHistoryProper.add_data(msg, 'warning')
def error(msg, *args):
Logger._error(msg)
LoggerHistoryProper.add_data(msg, 'error')
def info(msg, *args):
Logger._info(msg)
LoggerHistoryProper.add_data(msg, 'info')
Logger._exception = Logger.exception
Logger.exception = exception
Logger._warning = Logger.warning
Logger.warning = warning
Logger._error = Logger.error
Logger.error = error
Logger._info = Logger.info
Logger.info = info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment