Logging objects
The log in any software is useful for many aspects, one of them being exception handling. Kivy is always logging information about its performance. It creates a log file of every running of our app. Every programmer knows how helpful logging is for software engineering. In this recipe, we want to show information of our app in that log.
How to do it…
We will use a Python file with the MyW()
usual class where we will raise an error and display it in the Kivy log. To complete the recipe, follow these steps:
Import the usual
kivy
package.Import the
Logger
packages.Define the
MyW()
class.Trigger an info log.
Trigger a debug log.
Perform an exception.
Trigger an exception log:
import kivy kivy.require('1.9.0') from kivy.app import App from kivy.uix.widget import Widget from kivy.logger import Logger class MyW(Widget): Logger.info('MyW: This is an info message.') Logger.debug('MyW: This is a debug message.') try: raise Exception('exception') except Exception:...