Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom log handlers #1866

Merged
merged 8 commits into from
Jul 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ New in master
Features
--------

* Remove logging handlers (Issue #1797)
* Add ``-d``, ``--detach`` option to ``nikola serve`` (Issue #1871)
* Use provided teaser format (``*_READ_MORE_LINK``) with custom teaser text
(Issue #1879)
Expand Down
11 changes: 8 additions & 3 deletions nikola/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from . import __version__
from .plugin_categories import Command
from .nikola import Nikola
from .utils import sys_decode, sys_encode, get_root_dir, req_missing, LOGGER, STRICT_HANDLER, ColorfulStderrHandler
from .utils import sys_decode, sys_encode, get_root_dir, req_missing, LOGGER, STRICT_HANDLER, STDERR_HANDLER, ColorfulStderrHandler

if sys.version_info[0] == 3:
import importlib.machinery
Expand Down Expand Up @@ -88,13 +88,18 @@ def main(args=None):
break

quiet = False
strict = False
if len(args) > 0 and args[0] == 'build' and '--strict' in args:
LOGGER.notice('Running in strict mode')
STRICT_HANDLER.push_application()
strict = True
if len(args) > 0 and args[0] == 'build' and '-q' in args or '--quiet' in args:
nullhandler = NullHandler()
nullhandler.push_application()
NullHandler().push_application()
quiet = True
if not quiet and not strict:
NullHandler().push_application()
STDERR_HANDLER[0].push_application()

global config

original_cwd = os.getcwd()
Expand Down
20 changes: 0 additions & 20 deletions nikola/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -925,26 +925,6 @@ UNSLUGIFY_TITLES = True
# sometimes crash Nikola, your web server, or eat your cat.
# USE_SLUGIFY = True

# You can configure the logging handlers installed as plugins or change the
# log level of the default stderr handler.
# WARNING: The stderr handler allows only the loglevels of 'INFO' and 'DEBUG'.
# This is done for safety reasons, as blocking out anything other
# than 'DEBUG' may hide important information and break the user
# experience!

LOGGING_HANDLERS = {
'stderr': {'loglevel': 'INFO', '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
2 changes: 1 addition & 1 deletion nikola/nikola.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def __init__(self, **config):
self._template_system = None
self._THEMES = None
self.debug = DEBUG
self.loghandlers = []
self.loghandlers = utils.STDERR_HANDLER # TODO remove on v8
self.colorful = config.pop('__colorful__', False)
self.invariant = config.pop('__invariant__', False)
self.quiet = config.pop('__quiet__', False)
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/auto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@


from nikola.plugin_categories import Command
from nikola.utils import req_missing, get_logger, get_theme_path
from nikola.utils import req_missing, get_logger, get_theme_path, STDERR_HANDLER
LRJS_PATH = os.path.join(os.path.dirname(__file__), 'livereload.js')
error_signal = signal('error')
refresh_signal = signal('refresh')
Expand Down Expand Up @@ -116,7 +116,7 @@ class CommandAuto(Command):
def _execute(self, options, args):
"""Start the watcher."""

self.logger = get_logger('auto', self.site.loghandlers)
self.logger = get_logger('auto', STDERR_HANDLER)
LRSocket.logger = self.logger

if WebSocket is object and watchdog is None:
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import requests

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


def _call_nikola_list(site):
Expand Down Expand Up @@ -147,7 +147,7 @@ class CommandCheck(Command):

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

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/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from blinker import signal

from nikola.plugin_categories import Command
from nikola.utils import get_logger, remove_file, unicode_str, makedirs
from nikola.utils import get_logger, remove_file, unicode_str, makedirs, STDERR_HANDLER


class CommandDeploy(Command):
Expand All @@ -48,7 +48,7 @@ class CommandDeploy(Command):
logger = None

def _execute(self, command, args):
self.logger = get_logger('deploy', self.site.loghandlers)
self.logger = get_logger('deploy', STDERR_HANDLER)
# Get last successful deploy date
timestamp_path = os.path.join(self.site.config['CACHE_FOLDER'], 'lastdeploy')
if self.site.config['COMMENT_SYSTEM_ID'] == 'nikolademo':
Expand Down
6 changes: 2 additions & 4 deletions nikola/plugins/command/github_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

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

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

def _execute(self, command, args):

self.logger = get_logger(
CommandGitHubDeploy.name, self.site.loghandlers
)
self.logger = get_logger(CommandGitHubDeploy.name, STDERR_HANDLER)

# Check if ghp-import is installed
check_ghp_import_installed()
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from http.server import SimpleHTTPRequestHandler # NOQA

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


class IPv6Server(HTTPServer):
Expand Down Expand Up @@ -97,7 +97,7 @@ class CommandServe(Command):

def _execute(self, options, args):
"""Start test server."""
self.logger = get_logger('serve', self.site.loghandlers)
self.logger = get_logger('serve', STDERR_HANDLER)
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
4 changes: 2 additions & 2 deletions nikola/plugins/compile/ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
flag = None

from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing, get_logger
from nikola.utils import makedirs, req_missing, get_logger, STDERR_HANDLER


class CompileIPynb(PageCompiler):
Expand All @@ -61,7 +61,7 @@ class CompileIPynb(PageCompiler):
default_kernel = 'python2' if sys.version_info[0] == 2 else 'python3'

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

def compile_html(self, source, dest, is_two_file=True):
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/compile/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import docutils.writers.html4css1

from nikola.plugin_categories import PageCompiler
from nikola.utils import unicode_str, get_logger, makedirs, write_metadata
from nikola.utils import unicode_str, get_logger, makedirs, write_metadata, STDERR_HANDLER


class CompileRest(PageCompiler):
Expand Down Expand Up @@ -133,7 +133,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', site.loghandlers)
self.logger = get_logger('compile_rest', STDERR_HANDLER)
if not site.debug:
self.logger.level = 4

Expand Down
25 changes: 0 additions & 25 deletions nikola/plugins/loghandler/__init__.py

This file was deleted.

9 changes: 0 additions & 9 deletions nikola/plugins/loghandler/smtp.plugin

This file was deleted.

54 changes: 0 additions & 54 deletions nikola/plugins/loghandler/smtp.py

This file was deleted.

9 changes: 0 additions & 9 deletions nikola/plugins/loghandler/stderr.plugin

This file was deleted.

56 changes: 0 additions & 56 deletions nikola/plugins/loghandler/stderr.py

This file was deleted.

2 changes: 1 addition & 1 deletion nikola/plugins/task/bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BuildBundles(LateTask):
name = "create_bundles"

def set_site(self, site):
self.logger = utils.get_logger('bundles', site.loghandlers)
self.logger = utils.get_logger('bundles', utils.STDERR_HANDLER)
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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', site.loghandlers)
self.logger = utils.get_logger('render_galleries', utils.STDERR_HANDLER)

self.kw = {
'thumbnail_size': site.config['THUMBNAIL_SIZE'],
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/task/scale_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ScaleImage(Task, ImageProcessor):
name = "scale_images"

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

def process_tree(self, src, dst):
Expand Down
Loading