Skip to content
Permalink
Browse files
Merge pull request #1866 from getnikola/logging
Remove custom log handlers
  • Loading branch information
Kwpolska committed Jul 10, 2015
2 parents 77a5b46 + a2cd345 commit 0abee720345b6c99800102fb14f60722dec2052c
Show file tree
Hide file tree
Showing 21 changed files with 32 additions and 200 deletions.
@@ -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)
@@ -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
@@ -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()
@@ -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.
@@ -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)
@@ -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')
@@ -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:
@@ -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):
@@ -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())
@@ -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):
@@ -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':
@@ -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__

@@ -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()
@@ -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):
@@ -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))
@@ -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):
@@ -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):
@@ -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):
@@ -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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -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.')
@@ -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'],
@@ -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):

0 comments on commit 0abee72

Please sign in to comment.