use notify-level for your code?

Hey, I’m wondering if it’s possible to tell in my code to print debug messages depending on the notify-level Config vars like Panda classes.

Sure, see the examples in the Panda3D Python code, for instance in The idea is you first create a notify object, with something like:

notify = directNotify.newCategory("MyClassName")

By convention, we normally create this at the class level, though you could instead create it as a normal instance variable in the init() method if you prefer. In any case, you can then write debug messages with notify.debug(“Output message”).


This manual page describes this quite detailed:

Oh I must have missed that. Very simple to use.
This might be a general Python question, but what do you mean in the class level?

class Foo:
    stuff = 1
    moreStuff = 2

    def __init__(self):
        print self.stuff, self.moreStuff

This defines Foo.stuff and Foo.moreStuff as Foo class objects, which means they are shared by all instances of Foo. As opposed to the more usual kind of instance objects, which would be unique to each instance.