Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Way to record logs of Kivy to a different location on hard drive.
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = ('Kaan Akşit')
__version__ = '0.1'
# Importing necessary libraries.
try:
import sys,time,os,datetime,logging
from kivy.logger import Logger
from kivy.config import Config
except ImportError, err:
print "couldn't load module. %s" % (err)
sys.exit()
# Definition to harvest logs from Kivy's logging.
def HarvestLog(path):
cmd = 'rm %s' % path
os.system(cmd)
logger = logging.getLogger('kivy')
hdlr = logging.FileHandler(path)
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
return True
# Main definition.
def main():
HarvestLog('./session.log')
Logger.info('hello: world!)
return True
# What to initialize upon call.
if __name__ == '__main__':
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.