Skip to content

Commit

Permalink
Add a reasonable self.logger to all plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Alsina committed Mar 8, 2018
1 parent 8b2034f commit 3e733d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 10 additions & 4 deletions nikola/plugin_categories.py
Expand Up @@ -26,14 +26,15 @@

"""Nikola plugin categories."""

import sys
import os
import io
import os
import sys

from yapsy.IPlugin import IPlugin
import logbook
from doit.cmd_base import Command as DoitCommand
from yapsy.IPlugin import IPlugin

from .utils import LOGGER, first_line, req_missing
from .utils import LOGGER, first_line, get_logger, req_missing

try:
import typing # NOQA
Expand Down Expand Up @@ -63,10 +64,15 @@
class BasePlugin(IPlugin):
"""Base plugin class."""

logger = None

def set_site(self, site):
"""Set site, which is a Nikola instance."""
self.site = site
self.inject_templates()
self.logger = get_logger(self.name)
if not site.debug:
self.logger.level = logbook.base.WARNING

def inject_templates(self):
"""Inject 'templates/<engine>' (if exists) very early in the theme chain."""
Expand Down
4 changes: 0 additions & 4 deletions nikola/plugins/compile/rest/__init__.py
Expand Up @@ -185,10 +185,6 @@ def set_site(self, site):
self.config_dependencies.append(plugin_info.name)
plugin_info.plugin_object.short_help = plugin_info.description

self.logger = get_logger('compile_rest')
if not site.debug:
self.logger.level = logbook.base.WARNING


def get_observer(settings):
"""Return an observer for the docutils Reporter."""
Expand Down

0 comments on commit 3e733d6

Please sign in to comment.