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