Skip to content

Commit

Permalink
fix #1797 -- remove custom loghandlers
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 8, 2015
1 parent bbf0e4a commit 1272cd2
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 196 deletions.
11 changes: 8 additions & 3 deletions nikola/__main__.py
Expand Up @@ -48,7 +48,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 @@ -87,13 +87,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
Expand Up @@ -924,26 +924,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
1 change: 0 additions & 1 deletion nikola/nikola.py
Expand Up @@ -279,7 +279,6 @@ def __init__(self, **config):
self._template_system = None
self._THEMES = None
self.debug = DEBUG
self.loghandlers = []
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/check.py
Expand Up @@ -43,7 +43,7 @@
requests = None

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


def _call_nikola_list(site):
Expand Down Expand Up @@ -150,7 +150,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
Expand Up @@ -36,7 +36,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 @@ -49,7 +49,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
Expand Up @@ -34,7 +34,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 @@ -72,9 +72,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
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 @@ -89,7 +89,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/rest/__init__.py
Expand Up @@ -41,7 +41,7 @@
has_docutils = False

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


class CompileRest(PageCompiler):
Expand Down Expand Up @@ -148,7 +148,7 @@ def set_site(self, site):
plugin_info.plugin_object.set_site(site)
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
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
Expand Up @@ -69,7 +69,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
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
7 changes: 4 additions & 3 deletions nikola/utils.py
Expand Up @@ -116,14 +116,15 @@ def get_logger(name, handlers):
level=logbook.INFO if not DEBUG else logbook.DEBUG,
format_string=u'[{record.time:%Y-%m-%dT%H:%M:%SZ}] {record.level_name}: {record.channel}: {record.message}'
)]


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

USE_SLUGIFY = True

# This will block out the default handler and will hide all unwanted
# messages, properly.
logbook.NullHandler().push_application()
from logbook.compat import redirect_logging
redirect_logging()

if DEBUG:
logging.basicConfig(level=logging.DEBUG)
Expand Down
1 change: 0 additions & 1 deletion tests/base.py
Expand Up @@ -216,7 +216,6 @@ def __init__(self):
"RestExtension": RestExtension,
"MarkdownExtension": MarkdownExtension,
})
self.loghandlers = [nikola.utils.STDERR_HANDLER]
self.plugin_manager.setPluginInfoExtension('plugin')
if sys.version_info[0] == 3:
places = [
Expand Down

0 comments on commit 1272cd2

Please sign in to comment.