Skip to content
Permalink
Browse files
Add a reasonable self.logger to all plugins
  • Loading branch information
Roberto Alsina committed Mar 8, 2018
1 parent 8b2034f commit 3e733d6d2baf539f39f1919571af2c173fa94a79
Showing 2 changed files with 10 additions and 8 deletions.
@@ -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
@@ -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."""
@@ -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."""

0 comments on commit 3e733d6

Please sign in to comment.