diff --git a/monitord/plugins/dll-elf.cpp b/monitord/plugins/dll-elf.cpp index ece23fc..af13ae9 100644 --- a/monitord/plugins/dll-elf.cpp +++ b/monitord/plugins/dll-elf.cpp @@ -7,15 +7,20 @@ DLLManager::DLLManager( const char *fname ) { - // Try to open the library now and get any error message. + // Try to open the library now and get any error message. + LOG_INFO("Opening \"" << fname << "\"") - h=dlopen( fname, RTLD_NOW ); - if (h==NULL) + h = dlopen( fname, RTLD_NOW ); + + if (h == NULL) { err = dlerror(); LOG_ERROR("error loading library file \"" << fname << "\"" ) LOG_ERROR("root cause: \"" << err << "\"") } + else { + LOG_INFO("dlopen for \"" << fname << "\" succeeded") + } } @@ -23,7 +28,7 @@ { // close the library if it isn't null if( h!=0 ) - dlclose(h); + dlclose(h); } @@ -34,22 +39,33 @@ { // try extract a symbol from the library // get any error message is there is any + LOG_INFO("GetSymbol \"" << sym_name << "\"") if( h!=0 ) { + LOG_INFO("Calling dlsym \"" << sym_name << "\"") + *v = dlsym( h, sym_name ); - err=dlerror(); - if( err==0 ) - return true; - else { - *v=0 ; - return false; - } + err=dlerror(); + + if( err==0 ) { + LOG_INFO("Symbol found, initializing plug-in") + return true; + } + else { + LOG_ERROR("error getting symbol \"" << sym_name << "\"") + LOG_ERROR("root cause: \"" << err << "\"") + + *v=0 ; + return false; + } } else { + LOG_ERROR("No handle for dl found") + *v=0 ; - return false; + return false; } } @@ -65,15 +81,19 @@ const char *factory ) : DLLManager(fname) { + LOG_INFO("DLLFactoryBase: init") // try get the factory function if there is no error yet factory_func=0; - if( LastError()==0 ) + if( LastError() != NULL ) { - GetSymbol( (void **)&factory_func, factory ? factory : "factory0" ); + LOG_INFO("DllFactoryBase: trying to get symbol") + GetSymbol( (void **)&factory_func, factory ? factory : "factory0" ); } - + else { + LOG_ERROR("DLLFactoryBase: error occured") + } } diff --git a/monitord/plugins/dll.h b/monitord/plugins/dll.h index 04ddabd..f781e5c 100644 --- a/monitord/plugins/dll.h +++ b/monitord/plugins/dll.h @@ -7,6 +7,7 @@ #include #include #include +#include "../MonitorLogging.h" #ifdef WIN32 #include @@ -115,6 +116,8 @@ const char *func_name=0 ) : DLLFactoryBase( fname, func_name ) { + LOG_INFO("DllFactory entered fname=\"" << fname << "\", func_name=\"" << func_name << "\"" ) + if( factory_func ) factory = (T *)factory_func(); else