diff --git a/IPython/nbconvert/nbconvertapp.py b/IPython/nbconvert/nbconvertapp.py index 21a278b..254d4ff 100755 --- a/IPython/nbconvert/nbconvertapp.py +++ b/IPython/nbconvert/nbconvertapp.py @@ -17,6 +17,8 @@ Command-line interface for the NbConvert conversion utility. # Stdlib imports from __future__ import print_function + +import logging import sys import os import glob @@ -80,6 +82,9 @@ class NbConvertApp(BaseIPythonApplication): aliases = nbconvert_aliases flags = nbconvert_flags + def _log_level_default(self): + return logging.INFO + def _classes_default(self): classes = [NbConvertBase] for pkg in (exporters, transformers, writers): @@ -273,6 +278,7 @@ class NbConvertApp(BaseIPythonApplication): self.exit(1) for notebook_filename in self.notebooks: + self.log.info("Converting notebook %s to %s", notebook_filename, self.export_format) # Get a unique key for the notebook and set it in the resources object. basename = os.path.basename(notebook_filename) @@ -282,6 +288,7 @@ class NbConvertApp(BaseIPythonApplication): resources = {} resources['unique_key'] = notebook_name resources['output_files_dir'] = '%s_files' % notebook_name + self.log.debug("Writing extra files to %s", resources['output_files_dir']) # Try to export try: diff --git a/IPython/nbconvert/transformers/base.py b/IPython/nbconvert/transformers/base.py index 825808e..b9d18f6 100755 --- a/IPython/nbconvert/transformers/base.py +++ b/IPython/nbconvert/transformers/base.py @@ -79,8 +79,9 @@ class Transformer(NbConvertBase): Additional resources used in the conversion process. Allows transformers to pass variables into the Jinja engine. """ + self.log.debug("Applying transform: %s", self.__class__.__name__) try : - for worksheet in nb.worksheets : + for worksheet in nb.worksheets: for index, cell in enumerate(worksheet.cells): worksheet.cells[index], resources = self.transform_cell(cell, resources, index) return nb, resources diff --git a/IPython/nbconvert/utils/base.py b/IPython/nbconvert/utils/base.py index b7234f8..85e8426 100644 --- a/IPython/nbconvert/utils/base.py +++ b/IPython/nbconvert/utils/base.py @@ -12,13 +12,13 @@ #----------------------------------------------------------------------------- from IPython.utils.traitlets import List -from IPython.config.configurable import Configurable +from IPython.config.configurable import LoggingConfigurable #----------------------------------------------------------------------------- # Classes and functions #----------------------------------------------------------------------------- -class NbConvertBase(Configurable): +class NbConvertBase(LoggingConfigurable): """Global configurable class for shared config Usefull for display data priority that might be use by many trasnformers diff --git a/IPython/nbconvert/writers/files.py b/IPython/nbconvert/writers/files.py index 0d6c173..171e254 100644 --- a/IPython/nbconvert/writers/files.py +++ b/IPython/nbconvert/writers/files.py @@ -45,7 +45,12 @@ class FilesWriter(WriterBase): super(FilesWriter, self).__init__(**kw) self._build_directory_changed('build_directory', self.build_directory, self.build_directory) - + + def _makedir(self, path): + """Make a directory if it doesn't already exist""" + if not os.path.isdir(path): + self.log.info("Making directory %s", path) + os.makedirs(path) def write(self, output, resources, notebook_name=None, **kw): """ @@ -67,10 +72,10 @@ class FilesWriter(WriterBase): # Determine where to write the file to dest = os.path.join(self.build_directory, filename) path = os.path.dirname(dest) - if not os.path.isdir(path): - os.makedirs(path) + self._makedir(path) # Write file + self.log.info("Writing support file %s", dest) with io.open(dest, 'wb') as f: f.write(data) @@ -84,11 +89,11 @@ class FilesWriter(WriterBase): # Make sure folder exists. dest = os.path.join(self.build_directory, filename) path = os.path.dirname(dest) - if not os.path.isdir(path): - os.makedirs(path) + self._makedir(path) # Copy if destination is different. if not os.path.normpath(dest) == os.path.normpath(matching_filename): + self.log.info("Linking %s -> %s", matching_filename, dest) link_or_copy(matching_filename, dest) # Determine where to write conversion results. @@ -97,6 +102,7 @@ class FilesWriter(WriterBase): dest = os.path.join(self.build_directory, dest) # Write conversion results. + self.log.info("Writing %s", dest) with io.open(dest, 'w') as f: f.write(output) return dest \ No newline at end of file