Codebase list python-lml / 768ed69 docs / source / lml_log.rst
768ed69

Tree @768ed69 (Download .tar.gz)

lml_log.rst @768ed69view markup · raw · history · blame

Logging facility

During the development of lml package, the logging facility helps debugging a lot. Let me show you how to enable the logs of lml.

Enable the logging

Let us open robotchef's main.py. Insert the highlighted codes.

System Message: ERROR/3 (<string>, line 13)

Error in "code-block" directive: unknown option: "emphasize-lines".

.. code-block:: python
    :emphasize-lines: 5-10

    import sys

    from robotchef.plugin import CuisineManager, NoChefException

    import logging
    import logging.config

    logging.basicConfig(
        format='%(name)s:%(lineno)d - %(levelname)s - %(message)s',
        level=logging.DEBUG)


    def main():
        if len(sys.argv) < 2:
            sys.exit(-1)

        manager = CuisineManager()
    ...

Then you will need to run the installation again:

$ cd robotchef
$ python setup.py install

Let us run the command again:

$ robotchef "Jacket Potato"
lml.plugin:226 - DEBUG - declare 'cuisine' plugin manager
lml.loader:52 - DEBUG - scanning for plugins...
lml.utils:48 - DEBUG - found robotchef_allinone_lml
lml.plugin.PluginInfoChain:139 - DEBUG - add robotchef_britishcuisine.fry.Fry as 'cuisine' plugin
robotchef.plugin.CuisineManager:178 - DEBUG - load robotchef_britishcuisine.fry.Fry later
lml.plugin.PluginInfoChain:139 - DEBUG - add robotchef_britishcuisine.bake.Bake as 'cuisine' plugin
robotchef.plugin.CuisineManager:178 - DEBUG - load robotchef_britishcuisine.bake.Bake later
lml.utils:48 - DEBUG - found robotchef_britishcuisine
lml.plugin.PluginInfoChain:139 - DEBUG - add robotchef.robot_cuisine.electrify.Boost as 'cuisine' plugin
robotchef.plugin.CuisineManager:178 - DEBUG - load robotchef.robot_cuisine.electrify.Boost later
lml.utils:48 - DEBUG - found robotchef.robot_cuisine
lml.loader:82 - DEBUG - scanning done
robotchef.plugin.CuisineManager:160 - DEBUG - get a plugin called
robotchef.plugin.CuisineManager:210 - DEBUG - import robotchef_britishcuisine.bake.Bake
robotchef.plugin.CuisineManager:202 - DEBUG - load <class 'robotchef_britishcuisine.bake.Bake'> now for 'Jacket Potato'
I can bake Jacket Potato

Reading the log with the loading sequence,

_static/images/loading_sequence.svg

Three Chef plugins were discovered: robotchef_britishcuisine.fry.Fry, robotchef_britishcuisine.bake.Bake and robotchef.robot_cuisine.electricity.Boost. However, they are not imported yet. When the robotchef try to look up a plugin, it logs "get a plugin called". And it is actual time when a plugin is imported.