Skip to content

Commit

Permalink
logging: Log plugin name and extended version (plugins OpenCPN#27).
Browse files Browse the repository at this point in the history
Extend the logging when loading plugins to get the data needed to
verify plugin metadata including:
  - Plugin's name as of GetCommonName().
  - The extended semantic version available from API 117+.

Both of these items need to match the metadata file -- not logging
them will cause uncertainty and doubt.

See: OpenCPN/plugins#27
  • Loading branch information
Alec Leamas committed Feb 28, 2020
1 parent ab73351 commit 0d4761a
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/pluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ PlugInContainer *PlugInManager::LoadPlugIn(wxString plugin_file)

int pi_major = plug_in->GetPlugInVersionMajor();
int pi_minor = plug_in->GetPlugInVersionMinor();
int pi_ver = (pi_major * 100) + pi_minor;
SemanticVersion version(pi_major, pi_minor, -1);

if ( CheckBlacklistedPlugin(plug_in) ) {
delete pic;
Expand Down Expand Up @@ -2084,28 +2084,37 @@ PlugInContainer *PlugInManager::LoadPlugIn(wxString plugin_file)
break;

case 116:
case 117:
pic->m_pplugin = dynamic_cast<opencpn_plugin_116*>(plug_in);
break;

case 117:
pic->m_pplugin = dynamic_cast<opencpn_plugin_117*>(plug_in);
do /* force a local scope */ {
auto p = dynamic_cast<opencpn_plugin_117*>(plug_in);
version = SemanticVersion(pi_major, pi_minor,
p->GetPlugInVersionPatch(),
p->GetPlugInVersionPost(),
p->GetPlugInVersionPre(),
p->GetPlugInVersionBuild());
} while (false);
break;

default:
break;
}

if(pic->m_pplugin)
{
msg = _T("PlugInManager: ");
msg += plugin_file;
wxString msg1;
msg1.Printf(_T("\n API Version detected: %d"), api_ver);
msg += msg1;
msg1.Printf(_T("\n PlugIn Version detected: %d"), pi_ver);
msg += msg1;
wxLogMessage(msg);
std::stringstream msg;
msg << "PlugInManager: " << plugin_file
<< "\n Plugin common name: " << pic->m_pplugin->GetCommonName()
<< "\n API Version detected: " << api_ver
<< "\n PlugIn Version detected: " << version;
wxLogMessage(msg.str().c_str());
}
else
{
msg = _T(" ");
wxString msg = _T(" ");
msg += plugin_file;
wxString msg1 = _T(" cannot be loaded");
msg += msg1;
Expand Down

0 comments on commit 0d4761a

Please sign in to comment.