Browse Source

lodel.plugin.plugins.Plugin log messages enhancement

Yann Weber 8 years ago
parent
commit
3299dc549a
1 changed files with 11 additions and 3 deletions
  1. 11
    3
      lodel/plugin/plugins.py

+ 11
- 3
lodel/plugin/plugins.py View File

@@ -157,8 +157,6 @@ to generic PluginVersion comparison function : '%s'" % cmp_fun_name)
157 157
 # 1. Settings call start method to instanciate all plugins found in confs
158 158
 # 2. Settings fetch all confspecs
159 159
 # 3. the loader call load_all to register hooks etc
160
-#
161
-#@todo add log messages (now we can)
162 160
 class Plugin(object):
163 161
     
164 162
     ##@brief Stores plugin directories paths
@@ -587,6 +585,7 @@ name differ from the one found in plugin's init file"
587 585
     #@return a dict with name, version and path if path is a plugin module, else False
588 586
     @classmethod
589 587
     def dir_is_plugin(cls, path):
588
+        log_msg = "%s is not a plugin directory because : " % path
590 589
         #Checks that path exists
591 590
         if not os.path.isdir(path):
592 591
             raise ValueError(
@@ -594,15 +593,23 @@ name differ from the one found in plugin's init file"
594 593
         #Checks that path contains plugin's init file
595 594
         initfile = os.path.join(path, INIT_FILENAME)
596 595
         if not os.path.isfile(initfile):
596
+            log_msg += "'%s' not found" % (INIT_FILENAME)
597
+            logger.debug(log_msg)
597 598
             return False
598 599
         #Importing plugin's init file to check contained datas
599 600
         try:
600 601
             initmod, modname = cls.import_init(path)
601
-        except PluginError:
602
+        except PluginError as e:
603
+            log_msg += "unable to load '%s'. Exception raised : %s"
604
+            log_msg %= (INIT_FILENAME, e)
605
+            logger.debug(log_msg)
602 606
             return False
603 607
         #Checking mandatory init module variables
604 608
         for attr_name in MANDATORY_VARNAMES:
605 609
             if not hasattr(initmod,attr_name):
610
+                log_msg += " mandatory variable '%s' not found in '%s'"
611
+                log_msg %= (attr_name, INIT_FILENAME)
612
+                logger.debug(log_msg)
606 613
                 return False
607 614
         try:
608 615
             pversion = getattr(initmod, PLUGIN_VERSION_VARNAME)
@@ -650,6 +657,7 @@ name differ from the one found in plugin's init file"
650 657
                     #Check if it is a plugin directory
651 658
                     test_result = cls.dir_is_plugin(f_path)
652 659
                     if not (test_result is False):
660
+                        logger.info("Plugin found in %s" % f_path)
653 661
                         res.append(test_result)
654 662
                     else:
655 663
                         to_explore.append(f_path)

Loading…
Cancel
Save