Transmitter::Debug implementation 1/2
This also sorts switch() and listen_to() statements in order of severity: debug, info, warning, error, fatal, throw.
This commit is contained in:
parent
51871489ad
commit
e4e94e77c9
@ -61,10 +61,9 @@ load_session (string dir, string state)
|
||||
{
|
||||
SessionEvent::create_per_thread_pool ("test", 512);
|
||||
|
||||
test_receiver.listen_to (error);
|
||||
test_receiver.listen_to (info);
|
||||
test_receiver.listen_to (fatal);
|
||||
test_receiver.listen_to (warning);
|
||||
test_receiver.listen_to (error);
|
||||
test_receiver.listen_to (fatal);
|
||||
|
||||
AudioEngine* engine = AudioEngine::create ();
|
||||
|
||||
|
@ -28,15 +28,18 @@ TestReceiver::receive (Transmitter::Channel chn, const char * str)
|
||||
const char *prefix = "";
|
||||
|
||||
switch (chn) {
|
||||
case Transmitter::Error:
|
||||
prefix = ": [ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Debug:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Info:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Warning:
|
||||
prefix = ": [WARNING]: ";
|
||||
break;
|
||||
case Transmitter::Error:
|
||||
prefix = ": [ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Fatal:
|
||||
prefix = ": [FATAL]: ";
|
||||
break;
|
||||
|
@ -33,6 +33,9 @@ protected:
|
||||
case Transmitter::Error:
|
||||
prefix = ": [ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Debug:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Info:
|
||||
/* ignore */
|
||||
return;
|
||||
|
@ -43,10 +43,9 @@ TestUI::TestUI ()
|
||||
|
||||
SessionEvent::create_per_thread_pool ("test", 512);
|
||||
|
||||
m_test_receiver.listen_to (PBD::error);
|
||||
m_test_receiver.listen_to (PBD::info);
|
||||
m_test_receiver.listen_to (PBD::fatal);
|
||||
m_test_receiver.listen_to (PBD::warning);
|
||||
m_test_receiver.listen_to (PBD::error);
|
||||
m_test_receiver.listen_to (PBD::fatal);
|
||||
|
||||
/* We can't use VSTs here as we have a stub instead of the
|
||||
required bits in gtk2_ardour.
|
||||
|
@ -76,15 +76,18 @@ class DummyReceiver : public Receiver {
|
||||
void receive (Transmitter::Channel chn, const char * str) {
|
||||
const char *prefix = "";
|
||||
switch (chn) {
|
||||
case Transmitter::Error:
|
||||
prefix = "[ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Debug:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Info:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Warning:
|
||||
prefix = "[WARNING]: ";
|
||||
break;
|
||||
case Transmitter::Error:
|
||||
prefix = "[ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Fatal:
|
||||
prefix = "[FATAL]: ";
|
||||
break;
|
||||
@ -130,10 +133,9 @@ int main (int argc, char **argv) {
|
||||
|
||||
PBD::init();
|
||||
|
||||
dummy_receiver.listen_to (error);
|
||||
dummy_receiver.listen_to (info);
|
||||
dummy_receiver.listen_to (fatal);
|
||||
dummy_receiver.listen_to (warning);
|
||||
dummy_receiver.listen_to (error);
|
||||
dummy_receiver.listen_to (fatal);
|
||||
|
||||
std::vector<VSTInfo *> *infos = 0;
|
||||
|
||||
|
@ -52,8 +52,8 @@ protected:
|
||||
void receive (Transmitter::Channel chn, const char * str) {
|
||||
const char *prefix = "";
|
||||
switch (chn) {
|
||||
case Transmitter::Error:
|
||||
prefix = "[ERROR]: ";
|
||||
case Transmitter::Debug:
|
||||
/* ignore */
|
||||
break;
|
||||
case Transmitter::Info:
|
||||
prefix = "[Info]: ";
|
||||
@ -61,6 +61,9 @@ protected:
|
||||
case Transmitter::Warning:
|
||||
prefix = "[WARNING]: ";
|
||||
break;
|
||||
case Transmitter::Error:
|
||||
prefix = "[ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Fatal:
|
||||
prefix = "[FATAL]: ";
|
||||
break;
|
||||
@ -191,10 +194,10 @@ main (int argc, char **argv)
|
||||
PBD::init();
|
||||
|
||||
if (print_log) {
|
||||
log_receiver.listen_to (error);
|
||||
log_receiver.listen_to (info);
|
||||
log_receiver.listen_to (fatal);
|
||||
log_receiver.listen_to (warning);
|
||||
log_receiver.listen_to (error);
|
||||
log_receiver.listen_to (fatal);
|
||||
}
|
||||
|
||||
bool err = false;
|
||||
|
@ -162,6 +162,7 @@ UI::load_rcfile (string path, bool themechange)
|
||||
static Glib::RefPtr<Style>* error_style = 0;
|
||||
static Glib::RefPtr<Style>* warning_style = 0;
|
||||
static Glib::RefPtr<Style>* info_style = 0;
|
||||
static Glib::RefPtr<Style>* debug_style = 0;
|
||||
|
||||
if (path.length() == 0) {
|
||||
return -1;
|
||||
@ -196,6 +197,7 @@ UI::load_rcfile (string path, bool themechange)
|
||||
Label error_widget;
|
||||
Label warning_widget;
|
||||
Label info_widget;
|
||||
Label debug_widget;
|
||||
RefPtr<Gtk::Style> style;
|
||||
RefPtr<TextBuffer> buffer (errors->text().get_buffer());
|
||||
|
||||
@ -203,15 +205,18 @@ UI::load_rcfile (string path, bool themechange)
|
||||
box.pack_start (error_widget);
|
||||
box.pack_start (warning_widget);
|
||||
box.pack_start (info_widget);
|
||||
box.pack_start (debug_widget);
|
||||
|
||||
error_ptag = buffer->create_tag();
|
||||
error_mtag = buffer->create_tag();
|
||||
fatal_ptag = buffer->create_tag();
|
||||
fatal_mtag = buffer->create_tag();
|
||||
error_ptag = buffer->create_tag();
|
||||
error_mtag = buffer->create_tag();
|
||||
warning_ptag = buffer->create_tag();
|
||||
warning_mtag = buffer->create_tag();
|
||||
info_ptag = buffer->create_tag();
|
||||
info_mtag = buffer->create_tag();
|
||||
debug_ptag = buffer->create_tag();
|
||||
debug_mtag = buffer->create_tag();
|
||||
|
||||
fatal_widget.set_name ("FatalMessage");
|
||||
delete fatal_style;
|
||||
@ -270,15 +275,27 @@ UI::load_rcfile (string path, bool themechange)
|
||||
info_mtag->property_foreground_gdk().set_value((*info_style)->get_fg(STATE_NORMAL));
|
||||
info_mtag->property_background_gdk().set_value((*info_style)->get_bg(STATE_NORMAL));
|
||||
|
||||
debug_widget.set_name ("DebugMessage");
|
||||
delete debug_style;
|
||||
debug_style = new Glib::RefPtr<Style> (Glib::wrap (gtk_rc_get_style (reinterpret_cast<GtkWidget*> (debug_widget.gobj())), true));
|
||||
|
||||
debug_ptag->property_font_desc().set_value((*debug_style)->get_font());
|
||||
debug_ptag->property_foreground_gdk().set_value((*debug_style)->get_fg(STATE_ACTIVE));
|
||||
debug_ptag->property_background_gdk().set_value((*debug_style)->get_bg(STATE_ACTIVE));
|
||||
debug_mtag->property_font_desc().set_value((*debug_style)->get_font());
|
||||
debug_mtag->property_foreground_gdk().set_value((*debug_style)->get_fg(STATE_NORMAL));
|
||||
debug_mtag->property_background_gdk().set_value((*debug_style)->get_bg(STATE_NORMAL));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
UI::run (Receiver &old_receiver)
|
||||
{
|
||||
_receiver.listen_to (error);
|
||||
_receiver.listen_to (debug);
|
||||
_receiver.listen_to (info);
|
||||
_receiver.listen_to (warning);
|
||||
_receiver.listen_to (error);
|
||||
_receiver.listen_to (fatal);
|
||||
|
||||
/* stop the old receiver (text/console) once we hit the first idle */
|
||||
@ -572,6 +589,9 @@ UI::receive (Transmitter::Channel chn, const char *str)
|
||||
case Transmitter::Info:
|
||||
error_stack.push_back (string (X_("INFO: ")) + str);
|
||||
break;
|
||||
case Transmitter::Debug:
|
||||
error_stack.push_back (string (X_("Debug: ")) + str);
|
||||
break;
|
||||
case Transmitter::Throw:
|
||||
error_stack.push_back (string (X_("THROW: ")) + str);
|
||||
break;
|
||||
@ -618,17 +638,23 @@ UI::process_error_message (Transmitter::Channel chn, const char *str)
|
||||
mtag = error_mtag;
|
||||
prefix_len = 9;
|
||||
break;
|
||||
case Transmitter::Warning:
|
||||
prefix = "[WARNING]: ";
|
||||
ptag = warning_ptag;
|
||||
mtag = warning_mtag;
|
||||
prefix_len = 11;
|
||||
break;
|
||||
case Transmitter::Info:
|
||||
prefix = "[INFO]: ";
|
||||
ptag = info_ptag;
|
||||
mtag = info_mtag;
|
||||
prefix_len = 8;
|
||||
break;
|
||||
case Transmitter::Warning:
|
||||
prefix = "[WARNING]: ";
|
||||
ptag = warning_ptag;
|
||||
mtag = warning_mtag;
|
||||
prefix_len = 11;
|
||||
case Transmitter::Debug:
|
||||
prefix = "[DEBUG]: ";
|
||||
ptag = debug_ptag;
|
||||
mtag = debug_mtag;
|
||||
prefix_len = 9;
|
||||
break;
|
||||
default:
|
||||
/* no choice but to use text/console output here */
|
||||
|
@ -179,14 +179,16 @@ private:
|
||||
Gtk::Tooltips *tips;
|
||||
#endif
|
||||
TextViewer *errors;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> error_ptag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> error_mtag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> fatal_ptag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> fatal_mtag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> info_ptag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> info_mtag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> error_ptag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> error_mtag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> warning_ptag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> warning_mtag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> info_ptag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> info_mtag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> debug_ptag;
|
||||
Glib::RefPtr<Gtk::TextBuffer::Tag> debug_mtag;
|
||||
|
||||
static void signal_pipe_callback (void *, gint, GdkInputCondition);
|
||||
void process_error_message (Transmitter::Channel, const char *);
|
||||
|
@ -22,10 +22,12 @@
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/textreceiver.h"
|
||||
|
||||
Transmitter error (Transmitter::Error);
|
||||
Transmitter debug (Transmitter::Debug);
|
||||
Transmitter info (Transmitter::Info);
|
||||
Transmitter warning (Transmitter::Warning);
|
||||
Transmitter error (Transmitter::Error);
|
||||
Transmitter fatal (Transmitter::Fatal);
|
||||
|
||||
TextReceiver text_receiver ("mmctest");
|
||||
|
||||
#include "midi++/port.h"
|
||||
@ -58,10 +60,10 @@ main (int argc, char *argv[])
|
||||
{
|
||||
byte buf[1];
|
||||
|
||||
text_receiver.listen_to (error);
|
||||
text_receiver.listen_to (info);
|
||||
text_receiver.listen_to (fatal);
|
||||
text_receiver.listen_to (warning);
|
||||
text_receiver.listen_to (error);
|
||||
text_receiver.listen_to (fatal);
|
||||
|
||||
if (setup_midi ()) {
|
||||
exit (1);
|
||||
|
@ -22,9 +22,10 @@
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/textreceiver.h"
|
||||
|
||||
Transmitter error (Transmitter::Error);
|
||||
Transmitter debug (Transmitter::Debug);
|
||||
Transmitter info (Transmitter::Info);
|
||||
Transmitter warning (Transmitter::Warning);
|
||||
Transmitter error (Transmitter::Error);
|
||||
Transmitter fatal (Transmitter::Fatal);
|
||||
TextReceiver text_receiver ("mmctest");
|
||||
|
||||
@ -102,10 +103,10 @@ main (int argc, char *argv[])
|
||||
{
|
||||
byte buf[1];
|
||||
|
||||
text_receiver.listen_to (error);
|
||||
text_receiver.listen_to (info);
|
||||
text_receiver.listen_to (fatal);
|
||||
text_receiver.listen_to (warning);
|
||||
text_receiver.listen_to (error);
|
||||
text_receiver.listen_to (fatal);
|
||||
|
||||
if (setup_midi ()) {
|
||||
exit (1);
|
||||
|
@ -18,10 +18,10 @@ main ()
|
||||
|
||||
if (!PBD::init ()) return 1;
|
||||
|
||||
text_receiver.listen_to (PBD::error);
|
||||
text_receiver.listen_to (PBD::info);
|
||||
text_receiver.listen_to (PBD::fatal);
|
||||
text_receiver.listen_to (PBD::warning);
|
||||
text_receiver.listen_to (PBD::error);
|
||||
text_receiver.listen_to (PBD::fatal);
|
||||
|
||||
ScalarPropertiesTest::make_property_quarks ();
|
||||
|
||||
|
@ -67,15 +67,18 @@ protected:
|
||||
const char* prefix = "";
|
||||
|
||||
switch (chn) {
|
||||
case Transmitter::Error:
|
||||
prefix = "[ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Debug:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Info:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Warning:
|
||||
prefix = "[WARNING]: ";
|
||||
break;
|
||||
case Transmitter::Error:
|
||||
prefix = "[ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Fatal:
|
||||
prefix = "[FATAL]: ";
|
||||
break;
|
||||
@ -150,10 +153,9 @@ init ()
|
||||
|
||||
static LuaReceiver lua_receiver;
|
||||
|
||||
lua_receiver.listen_to (error);
|
||||
lua_receiver.listen_to (info);
|
||||
lua_receiver.listen_to (fatal);
|
||||
lua_receiver.listen_to (warning);
|
||||
lua_receiver.listen_to (error);
|
||||
lua_receiver.listen_to (fatal);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -20,11 +20,14 @@
|
||||
#include <cstdlib>
|
||||
#include <glibmm.h>
|
||||
|
||||
|
||||
#include "pbd/debug.h"
|
||||
#include "pbd/event_loop.h"
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/failed_constructor.h"
|
||||
#include "pbd/pthread_utils.h"
|
||||
#include "pbd/receiver.h"
|
||||
#include "pbd/transmitter.h"
|
||||
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/filename_extensions.h"
|
||||
@ -37,41 +40,46 @@ using namespace ARDOUR;
|
||||
using namespace PBD;
|
||||
|
||||
static const char* localedir = LOCALEDIR;
|
||||
TestReceiver test_receiver;
|
||||
|
||||
void
|
||||
TestReceiver::receive (Transmitter::Channel chn, const char * str)
|
||||
class LogReceiver : public Receiver
|
||||
{
|
||||
const char *prefix = "";
|
||||
protected:
|
||||
void receive (Transmitter::Channel chn, const char * str) {
|
||||
const char *prefix = "";
|
||||
switch (chn) {
|
||||
case Transmitter::Debug:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Info:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Warning:
|
||||
prefix = ": [WARNING]: ";
|
||||
break;
|
||||
case Transmitter::Error:
|
||||
prefix = ": [ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Fatal:
|
||||
prefix = ": [FATAL]: ";
|
||||
break;
|
||||
case Transmitter::Throw:
|
||||
/* this isn't supposed to happen */
|
||||
abort ();
|
||||
}
|
||||
|
||||
switch (chn) {
|
||||
case Transmitter::Error:
|
||||
prefix = ": [ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Info:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Warning:
|
||||
prefix = ": [WARNING]: ";
|
||||
break;
|
||||
case Transmitter::Fatal:
|
||||
prefix = ": [FATAL]: ";
|
||||
break;
|
||||
case Transmitter::Throw:
|
||||
/* this isn't supposed to happen */
|
||||
abort ();
|
||||
/* note: iostreams are already thread-safe: no external
|
||||
lock required.
|
||||
*/
|
||||
|
||||
std::cout << prefix << str << std::endl;
|
||||
|
||||
if (chn == Transmitter::Fatal) {
|
||||
::exit (9);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* note: iostreams are already thread-safe: no external
|
||||
lock required.
|
||||
*/
|
||||
|
||||
std::cout << prefix << str << std::endl;
|
||||
|
||||
if (chn == Transmitter::Fatal) {
|
||||
::exit (9);
|
||||
}
|
||||
}
|
||||
LogReceiver log_receiver;
|
||||
|
||||
/* temporarily required due to some code design confusion (Feb 2014) */
|
||||
|
||||
@ -116,10 +124,9 @@ SessionUtils::init (bool print_log)
|
||||
SessionEvent::create_per_thread_pool ("util", 512);
|
||||
|
||||
if (print_log) {
|
||||
test_receiver.listen_to (error);
|
||||
test_receiver.listen_to (info);
|
||||
test_receiver.listen_to (fatal);
|
||||
test_receiver.listen_to (warning);
|
||||
log_receiver.listen_to (warning);
|
||||
log_receiver.listen_to (error);
|
||||
log_receiver.listen_to (fatal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,18 +19,9 @@
|
||||
#ifndef _session_utils_common_h_
|
||||
#define _session_utils_common_h_
|
||||
|
||||
#include "pbd/transmitter.h"
|
||||
#include "pbd/receiver.h"
|
||||
|
||||
#include "ardour/ardour.h"
|
||||
#include "ardour/session.h"
|
||||
|
||||
class TestReceiver : public Receiver
|
||||
{
|
||||
protected:
|
||||
void receive (Transmitter::Channel chn, const char * str);
|
||||
};
|
||||
|
||||
namespace SessionUtils {
|
||||
|
||||
/** initialize libardour */
|
||||
|
Loading…
Reference in New Issue
Block a user