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:

  1. Import the usual kivy package.
  2. Import the Logger packages.
  3. Define the MyW() class.
  4. Trigger an info log.
  5. Trigger a debug log.
  6. Perform an exception.
  7. Trigger an exception log:
    import kivy kivy.require('1.9.0') from kivy.app import App from ...

Get Kivy Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.