notify-output foo.txt does not work on festy

notify-output foo.txt

i have tried putting every thing i can think of in to the string, even the c++ code seam to be clear, but it just does not work!

00491 ////////////////////////////////////////////////////////////////////
00492 //     Function: Notify::config_initialized
00493 //       Access: Public
00494 //  Description: Intended to be called only by Config, this is a
00495 //               callback that indicated to Notify when Config has
00496 //               done initializing and Notify can safely set up some
00497 //               internal state variables that depend on Config
00498 //               variables.
00499 ////////////////////////////////////////////////////////////////////
00500 void Notify::
00501 config_initialized() {
00502   static bool already_initialized = false;
00503   if (already_initialized) {
00504     nout << "Notify::config_initialized() called more than once.\n";
00505     return;
00506   }
00507   already_initialized = true;
00508 
00509   if (_ostream_ptr == &cerr) {
00510     string notify_output = config_notify.GetString("notify-output", "");
00511     if (!notify_output.empty()) {
00512       if (notify_output == "stdout") {
00513         cout.setf(ios::unitbuf);
00514         set_ostream_ptr(&cout, false);
00515 
00516       } else if (notify_output == "stderr") {
00517         set_ostream_ptr(&cerr, false);
00518 
00519       } else {
00520         Filename filename = notify_output;
00521         filename.set_text();
00522         ofstream *out = new ofstream;
00523         if (!filename.open_write(*out)) {
00524           nout << "Unable to open file " << filename << " for output.\n";
00525           delete out;
00526         } else {
00527           out->setf(ios::unitbuf);
00528           set_ostream_ptr(out, true);
00529         }
00530       }
00531     }
00532   }
00533 }

There are two systems within Panda, both called Notify. There is the C++ notify system, which includes all the messages generated from low-level C++ code, and there is the Python DirectNotify system, which implements the python “notify” class and includes all of the messages generated by Python code.

Setting notify-output will only affect the low-level C++ system. For instance, it squelches all of the output from pview, which is purely C++. But it doesn’t affect most of the output you get from importing DirectStart.

The easiest way to redirect the notify output from Python is to reassign sys.stderr, e.g.:

        log = open(logfile, 'a')
        sys.stdout = log
        sys.stderr = log

David

thanks david!