Skip to content

Commit

Permalink
Remove all leftover loghandlers support
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jun 16, 2017
1 parent 4f2574c commit 330b5e4
Show file tree
Hide file tree
Showing 24 changed files with 36 additions and 57 deletions.
1 change: 0 additions & 1 deletion nikola/nikola.py
Expand Up @@ -616,7 +616,6 @@ def __init__(self, **config):
'DEPLOY_FUTURE': False,
'SCHEDULE_ALL': False,
'SCHEDULE_RULE': '',
'LOGGING_HANDLERS': {'stderr': {'loglevel': 'WARNING', 'bubble': True}},
'DEMOTE_HEADERS': 1,
'GITHUB_SOURCE_BRANCH': 'master',
'GITHUB_DEPLOY_BRANCH': 'gh-pages',
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/auto/__init__.py
Expand Up @@ -61,7 +61,7 @@
PatternMatchingEventHandler = object

from nikola.plugin_categories import Command
from nikola.utils import dns_sd, req_missing, get_logger, get_theme_path, STDERR_HANDLER
from nikola.utils import dns_sd, req_missing, get_logger, get_theme_path
LRJS_PATH = os.path.join(os.path.dirname(__file__), 'livereload.js')
error_signal = signal('error')
refresh_signal = signal('refresh')
Expand Down Expand Up @@ -129,7 +129,7 @@ class CommandAuto(Command):

def _execute(self, options, args):
"""Start the watcher."""
self.logger = get_logger('auto', STDERR_HANDLER)
self.logger = get_logger('auto')
LRSocket.logger = self.logger

if WebSocket is object and watchdog is None:
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/bootswatch_theme.py
Expand Up @@ -32,7 +32,7 @@
from nikola.plugin_categories import Command
from nikola import utils

LOGGER = utils.get_logger('bootswatch_theme', utils.STDERR_HANDLER)
LOGGER = utils.get_logger('bootswatch_theme')


def _check_for_theme(theme, themes):
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/check.py
Expand Up @@ -43,7 +43,7 @@
import requests

from nikola.plugin_categories import Command
from nikola.utils import get_logger, STDERR_HANDLER
from nikola.utils import get_logger


def _call_nikola_list(site, cache=None):
Expand Down Expand Up @@ -158,7 +158,7 @@ class CommandCheck(Command):

def _execute(self, options, args):
"""Check the generated site."""
self.logger = get_logger('check', STDERR_HANDLER)
self.logger = get_logger('check')

if not options['links'] and not options['files'] and not options['clean']:
print(self.help())
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/console.py
Expand Up @@ -31,9 +31,9 @@

from nikola import __version__
from nikola.plugin_categories import Command
from nikola.utils import get_logger, STDERR_HANDLER, req_missing, Commands
from nikola.utils import get_logger, req_missing, Commands

LOGGER = get_logger('console', STDERR_HANDLER)
LOGGER = get_logger('console')


class CommandConsole(Command):
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/deploy.py
Expand Up @@ -37,7 +37,7 @@
from blinker import signal

from nikola.plugin_categories import Command
from nikola.utils import get_logger, clean_before_deployment, STDERR_HANDLER
from nikola.utils import get_logger, clean_before_deployment


class CommandDeploy(Command):
Expand All @@ -52,7 +52,7 @@ class CommandDeploy(Command):

def _execute(self, command, args):
"""Execute the deploy command."""
self.logger = get_logger('deploy', STDERR_HANDLER)
self.logger = get_logger('deploy')
# Get last successful deploy date
timestamp_path = os.path.join(self.site.config['CACHE_FOLDER'], 'lastdeploy')

Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/github_deploy.py
Expand Up @@ -32,7 +32,7 @@

from nikola.plugin_categories import Command
from nikola.plugins.command.check import real_scan_files
from nikola.utils import get_logger, req_missing, clean_before_deployment, STDERR_HANDLER
from nikola.utils import get_logger, req_missing, clean_before_deployment
from nikola.__main__ import main
from nikola import __version__

Expand Down Expand Up @@ -82,7 +82,7 @@ class CommandGitHubDeploy(Command):

def _execute(self, options, args):
"""Run the deployment."""
self.logger = get_logger(CommandGitHubDeploy.name, STDERR_HANDLER)
self.logger = get_logger(CommandGitHubDeploy.name)

# Check if ghp-import is installed
check_ghp_import_installed()
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/import_wordpress.py
Expand Up @@ -58,7 +58,7 @@
from nikola.plugins.basic_import import ImportMixin, links
from nikola.plugins.command.init import SAMPLE_CONF, prepare_config, format_default_translations_config

LOGGER = utils.get_logger('import_wordpress', utils.STDERR_HANDLER)
LOGGER = utils.get_logger('import_wordpress')


def install_plugin(site, plugin_name, output_dir=None, show_install_notes=False):
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/init.py
Expand Up @@ -42,11 +42,11 @@
import nikola
from nikola.nikola import DEFAULT_INDEX_READ_MORE_LINK, DEFAULT_FEED_READ_MORE_LINK, LEGAL_VALUES, urlsplit, urlunsplit
from nikola.plugin_categories import Command
from nikola.utils import ask, ask_yesno, get_logger, makedirs, STDERR_HANDLER, load_messages
from nikola.utils import ask, ask_yesno, get_logger, makedirs, load_messages
from nikola.packages.tzlocal import get_localzone


LOGGER = get_logger('init', STDERR_HANDLER)
LOGGER = get_logger('init')

SAMPLE_CONF = {
'BLOG_AUTHOR': "Your Name",
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/new_post.py
Expand Up @@ -41,8 +41,8 @@
from nikola import utils

COMPILERS_DOC_LINK = 'https://getnikola.com/handbook.html#configuring-other-input-formats'
POSTLOGGER = utils.get_logger('new_post', utils.STDERR_HANDLER)
PAGELOGGER = utils.get_logger('new_page', utils.STDERR_HANDLER)
POSTLOGGER = utils.get_logger('new_post')
PAGELOGGER = utils.get_logger('new_page')
LOGGER = POSTLOGGER


Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/plugin.py
Expand Up @@ -41,7 +41,7 @@
from nikola.plugin_categories import Command
from nikola import utils

LOGGER = utils.get_logger('plugin', utils.STDERR_HANDLER)
LOGGER = utils.get_logger('plugin')


class CommandPlugin(Command):
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/serve.py
Expand Up @@ -46,7 +46,7 @@


from nikola.plugin_categories import Command
from nikola.utils import dns_sd, get_logger, STDERR_HANDLER
from nikola.utils import dns_sd, get_logger


class IPv6Server(HTTPServer):
Expand Down Expand Up @@ -120,7 +120,7 @@ def shutdown(self, signum=None, _frame=None):

def _execute(self, options, args):
"""Start test server."""
self.logger = get_logger('serve', STDERR_HANDLER)
self.logger = get_logger('serve')
out_dir = self.site.config['OUTPUT_FOLDER']
if not os.path.isdir(out_dir):
self.logger.error("Missing '{0}' folder?".format(out_dir))
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/theme.py
Expand Up @@ -41,7 +41,7 @@
from nikola.plugin_categories import Command
from nikola import utils

LOGGER = utils.get_logger('theme', utils.STDERR_HANDLER)
LOGGER = utils.get_logger('theme')


class CommandTheme(Command):
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/compile/ipynb.py
Expand Up @@ -42,7 +42,7 @@

from nikola import shortcodes as sc
from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing, get_logger, STDERR_HANDLER, LocaleBorg
from nikola.utils import makedirs, req_missing, get_logger, LocaleBorg


class CompileIPynb(PageCompiler):
Expand All @@ -55,7 +55,7 @@ class CompileIPynb(PageCompiler):

def set_site(self, site):
"""Set Nikola site."""
self.logger = get_logger('compile_ipynb', STDERR_HANDLER)
self.logger = get_logger('compile_ipynb')
super(CompileIPynb, self).set_site(site)

def _compile_string(self, nb_json):
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/compile/markdown/mdx_gist.py
Expand Up @@ -87,11 +87,11 @@
Extension = Pattern = object

from nikola.plugin_categories import MarkdownExtension
from nikola.utils import get_logger, STDERR_HANDLER
from nikola.utils import get_logger

import requests

LOGGER = get_logger('compile_markdown.mdx_gist', STDERR_HANDLER)
LOGGER = get_logger('compile_markdown.mdx_gist')

GIST_JS_URL = "https://gist.github.com/{0}.js"
GIST_FILE_JS_URL = "https://gist.github.com/{0}.js?file={1}"
Expand Down
3 changes: 1 addition & 2 deletions nikola/plugins/compile/rest/__init__.py
Expand Up @@ -46,7 +46,6 @@
get_logger,
makedirs,
write_metadata,
STDERR_HANDLER,
LocaleBorg,
map_metadata
)
Expand Down Expand Up @@ -186,7 +185,7 @@ 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', STDERR_HANDLER)
self.logger = get_logger('compile_rest')
if not site.debug:
self.logger.level = 4

Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/misc/scan_posts.py
Expand Up @@ -34,7 +34,7 @@
from nikola import utils
from nikola.post import Post

LOGGER = utils.get_logger('scan_posts', utils.STDERR_HANDLER)
LOGGER = utils.get_logger('scan_posts')


class ScanPosts(PostScanner):
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/shortcode/emoji/__init__.py
Expand Up @@ -12,7 +12,7 @@

TABLE = {}

LOGGER = utils.get_logger('scan_posts', utils.STDERR_HANDLER)
LOGGER = utils.get_logger('scan_posts')


def _populate():
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/task/bundles.py
Expand Up @@ -45,7 +45,7 @@ class BuildBundles(LateTask):

def set_site(self, site):
"""Set Nikola site."""
self.logger = utils.get_logger('bundles', utils.STDERR_HANDLER)
self.logger = utils.get_logger('bundles')
if webassets is None and site.config['USE_BUNDLES']:
utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)
self.logger.warn('Setting USE_BUNDLES to False.')
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/task/galleries.py
Expand Up @@ -66,7 +66,7 @@ def set_site(self, site):
site.register_path_handler('gallery_global', self.gallery_global_path)
site.register_path_handler('gallery_rss', self.gallery_rss_path)

self.logger = utils.get_logger('render_galleries', utils.STDERR_HANDLER)
self.logger = utils.get_logger('render_galleries')

self.kw = {
'thumbnail_size': site.config['THUMBNAIL_SIZE'],
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/task/scale_images.py
Expand Up @@ -40,7 +40,7 @@ class ScaleImage(Task, ImageProcessor):

def set_site(self, site):
"""Set Nikola site."""
self.logger = utils.get_logger('scale_images', utils.STDERR_HANDLER)
self.logger = utils.get_logger('scale_images')
return super(ScaleImage, self).set_site(site)

def process_tree(self, src, dst):
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/template/mako.py
Expand Up @@ -36,9 +36,9 @@
from markupsafe import Markup # It's ok, Mako requires it

from nikola.plugin_categories import TemplateSystem
from nikola.utils import makedirs, get_logger, STDERR_HANDLER
from nikola.utils import makedirs, get_logger

LOGGER = get_logger('mako', STDERR_HANDLER)
LOGGER = get_logger('mako')


class MakoTemplates(TemplateSystem):
Expand Down
12 changes: 4 additions & 8 deletions nikola/utils.py
Expand Up @@ -129,14 +129,10 @@ def should_colorize(self, record):
return self._colorful


def get_logger(name, handlers):
def get_logger(name, handlers=None):
"""Get a logger with handlers attached."""
l = logbook.Logger(name)
for h in handlers:
if isinstance(h, list):
l.handlers += h
else:
l.handlers.append(h)
l.handlers += STDERR_HANDLER
return l


Expand All @@ -146,7 +142,7 @@ def get_logger(name, handlers):
)]


LOGGER = get_logger('Nikola', STDERR_HANDLER)
LOGGER = get_logger('Nikola')
STRICT_HANDLER = ExceptionHandler(ApplicationWarning, level='WARNING')

USE_SLUGIFY = True
Expand All @@ -165,7 +161,7 @@ def showwarning(message, category, filename, lineno, file=None, line=None):
n = category.__name__
except AttributeError:
n = str(category)
get_logger(n, STDERR_HANDLER).warn('{0}:{1}: {2}'.format(filename, lineno, message))
get_logger(n).warn('{0}:{1}: {2}'.format(filename, lineno, message))


warnings.showwarning = showwarning
Expand Down
15 changes: 0 additions & 15 deletions tests/data/translated_titles/conf.py
Expand Up @@ -719,21 +719,6 @@
# (defaults to 1.)
# DEMOTE_HEADERS = 1

# You can configure the logging handlers installed as plugins or change the
# log level of the default stdout handler.
LOGGING_HANDLERS = {
'stderr': {'loglevel': 'WARNING', 'bubble': True},
# 'smtp': {
# 'from_addr': 'test-errors@example.com',
# 'recipients': ('test@example.com'),
# 'credentials':('testusername', 'password'),
# 'server_addr': ('127.0.0.1', 25),
# 'secure': (),
# 'level': 'DEBUG',
# 'bubble': True
# }
}

# Templates will use those filters, along with the defaults.
# Consult your engine's documentation on filters if you need help defining
# those.
Expand Down

0 comments on commit 330b5e4

Please sign in to comment.