Add more support for debugging plugins.
Added support for plugin debug messages and better error reporting when something goes wrong during start up of SLPlugin. Also added more debug output regarding general plugin messages as well as debug output related to AIFilePicker.
This commit is contained in:
@@ -41,6 +41,9 @@
|
||||
|
||||
// TODO: Make sure that the only symbol exported from this library is LLPluginInitEntryPoint
|
||||
|
||||
// Used for logging.
|
||||
BasicPluginBase* BasicPluginBase::sPluginBase;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Basic plugin constructor.
|
||||
///
|
||||
@@ -49,6 +52,8 @@
|
||||
BasicPluginBase::BasicPluginBase(LLPluginInstance::sendMessageFunction send_message_function, LLPluginInstance* plugin_instance) :
|
||||
mPluginInstance(plugin_instance), mSendMessageFunction(send_message_function), mDeleteMe(false)
|
||||
{
|
||||
llassert(!sPluginBase);
|
||||
sPluginBase = this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,9 +98,25 @@ void BasicPluginBase::staticReceiveMessage(char const* message_string, BasicPlug
|
||||
void BasicPluginBase::sendMessage(const LLPluginMessage &message)
|
||||
{
|
||||
std::string output = message.generate();
|
||||
PLS_DEBUGS << "BasicPluginBase::sendMessage: Sending: " << output << PLS_ENDL;
|
||||
mSendMessageFunction(output.c_str(), &mPluginInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send debug log message to plugin loader shell.
|
||||
*
|
||||
* @param[in] message Log message being sent to plugin loader shell
|
||||
* @param[in] level Log message level, enum of LLPluginMessage::LLPLUGIN_LOG_LEVEL
|
||||
*
|
||||
*/
|
||||
void BasicPluginBase::sendLogMessage(std::string const& message, LLPluginMessage::LLPLUGIN_LOG_LEVEL level)
|
||||
{
|
||||
LLPluginMessage logmessage(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "log_message");
|
||||
logmessage.setValue("message", message);
|
||||
logmessage.setValueS32("log_level",level);
|
||||
mSendMessageFunction(logmessage.generate().c_str(), &mPluginInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send shutdown message to the plugin loader shell.
|
||||
*
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llplugininstance.h"
|
||||
@@ -49,7 +51,7 @@ class BasicPluginBase
|
||||
public:
|
||||
BasicPluginBase(LLPluginInstance::sendMessageFunction send_message_function, LLPluginInstance* plugin_instance);
|
||||
//! Basic plugin destructor.
|
||||
virtual ~BasicPluginBase() {}
|
||||
virtual ~BasicPluginBase() { sPluginBase = NULL; }
|
||||
|
||||
//! Handle received message from plugin loader shell.
|
||||
virtual void receiveMessage(char const* message_string) = 0;
|
||||
@@ -57,6 +59,12 @@ public:
|
||||
// This function is actually called and then calls the member function above.
|
||||
static void staticReceiveMessage(char const* message_string, BasicPluginBase** self_ptr);
|
||||
|
||||
// Pointer to self used for logging (this object should be a singleton).
|
||||
static BasicPluginBase* sPluginBase;
|
||||
|
||||
// Used for log messages. Use macros below.
|
||||
void sendLogMessage(std::string const& message, LLPluginMessage::LLPLUGIN_LOG_LEVEL level);
|
||||
|
||||
// Shoot down the whole process.
|
||||
void sendShutdownMessage(void);
|
||||
|
||||
@@ -87,5 +95,38 @@ int create_plugin(
|
||||
LLPluginInstance* plugin_instance,
|
||||
BasicPluginBase** plugin_object);
|
||||
|
||||
#if LL_DEBUG
|
||||
#define LL_DEBUG_PLUGIN_MESSAGES 1
|
||||
#else
|
||||
#define LL_DEBUG_PLUGIN_MESSAGES 0
|
||||
#endif
|
||||
|
||||
/** Convenience macros for calling BasicPluginBase::sendLogMessage.
|
||||
* To log a message, use one of:
|
||||
* @code
|
||||
* PLS_DEBUGS << "Hello debug!" << PLS_ENDL;
|
||||
* PLS_INFOS << "Hello info!" << PLS_ENDL;
|
||||
* PLS_WARNS << "Hello warning!" << PLS_ENDL;
|
||||
* PLS_ERRS << "Hello error!" << PLS_ENDL;
|
||||
* @endcode
|
||||
*/
|
||||
#define PLS_LOG_MESSAGE(level, generate_code) \
|
||||
do { \
|
||||
if (generate_code && BasicPluginBase::sPluginBase) \
|
||||
{ \
|
||||
LLPluginMessage::LLPLUGIN_LOG_LEVEL _pls_log_msg_level = level;\
|
||||
std::ostringstream _pls_log_msg_stream; \
|
||||
_pls_log_msg_stream
|
||||
#define PLS_ENDL \
|
||||
LLError::End(); \
|
||||
BasicPluginBase::sPluginBase->sendLogMessage(_pls_log_msg_stream.str(), _pls_log_msg_level); \
|
||||
} \
|
||||
} while(0)
|
||||
// Only send plugin log messages of level info and lower when compiled with debugging.
|
||||
#define PLS_DEBUGS PLS_LOG_MESSAGE(LLPluginMessage::LOG_LEVEL_DEBUG, LL_DEBUG_PLUGIN_MESSAGES)
|
||||
#define PLS_INFOS PLS_LOG_MESSAGE(LLPluginMessage::LOG_LEVEL_INFO, LL_DEBUG_PLUGIN_MESSAGES)
|
||||
#define PLS_WARNS PLS_LOG_MESSAGE(LLPluginMessage::LOG_LEVEL_WARN, 1)
|
||||
#define PLS_ERRS PLS_LOG_MESSAGE(LLPluginMessage::LOG_LEVEL_ERR, 1)
|
||||
|
||||
#endif // BASIC_PLUGIN_BASE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user