Skip to content
Permalink
Browse files
fix #1797 -- remove custom loghandlers
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jun 8, 2015
1 parent bbf0e4a commit 1272cd23885efe1eb30b37e745502c15dc9bcc53
@@ -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
@@ -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()
@@ -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.
@@ -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)
@@ -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):
@@ -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())
@@ -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):
@@ -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':
@@ -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__

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

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

0 comments on commit 1272cd2

Please sign in to comment.