Skip to content

Commit

Permalink
Merge pull request #2735 from jmchilton/logging_dedup
Browse files Browse the repository at this point in the history
Slightly revise auto configuration of loggers
  • Loading branch information
martenson committed Aug 5, 2016
2 parents 08d20b2 + 9b86eae commit 2ebef64
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 49 deletions.
2 changes: 1 addition & 1 deletion config/tool_shed.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ threadpool_kill_thread_limit = 10800

# Specifies the factory for the universe WSGI application
paste.app_factory = galaxy.webapps.tool_shed.buildapp:app_factory
log_level = DEBUG
#log_level = DEBUG

# Database connection
database_file = database/community.sqlite
Expand Down
11 changes: 8 additions & 3 deletions lib/galaxy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,14 @@ def configure_logging( config ):
log.info( "Logging at '%s' level to '%s'" % ( level, destination ) )
# Set level
root.setLevel( level )
# Turn down paste httpserver logging
if level <= logging.DEBUG:
logging.getLogger( "paste.httpserver.ThreadPool" ).setLevel( logging.WARN )

disable_chatty_loggers = string_as_bool( config.get( "auto_configure_logging_disable_chatty", "True" ) )
if disable_chatty_loggers:
# Turn down paste httpserver logging
if level <= logging.DEBUG:
for chatty_logger in ["paste.httpserver.ThreadPool"]:
logging.getLogger( chatty_logger ).setLevel( logging.WARN )

# Remove old handlers
for h in root.handlers[:]:
root.removeHandler(h)
Expand Down
4 changes: 3 additions & 1 deletion lib/galaxy/webapps/tool_shed/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
from galaxy.openid.providers import OpenIDProviders
from galaxy.util.dbkeys import GenomeBuilds
from galaxy.web import security
from galaxy.config import configure_logging
import tool_shed.repository_registry
import tool_shed.repository_types.registry
from tool_shed.grids.repository_grid_filter_manager import RepositoryGridFilterManager

import logging
log = logging.getLogger( __name__ )

Expand All @@ -26,7 +28,7 @@ def __init__( self, **kwd ):
# Read the tool_shed.ini configuration file and check for errors.
self.config = config.Configuration( **kwd )
self.config.check()
config.configure_logging( self.config )
configure_logging( self.config )
# Initialize the Galaxy datatypes registry.
self.datatypes_registry = galaxy.datatypes.registry.Registry()
self.datatypes_registry.load_datatypes( self.config.root, self.config.datatypes_config )
Expand Down
44 changes: 0 additions & 44 deletions lib/galaxy/webapps/tool_shed/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import os
import re
import sys
import logging
import logging.config
import ConfigParser
Expand Down Expand Up @@ -253,46 +252,3 @@ def get_database_engine_options( kwargs ):
value = conversions[key](value)
rval[ key ] = value
return rval


def configure_logging( config ):
"""
Allow some basic logging configuration to be read from the cherrpy
config.
"""
# PasteScript will have already configured the logger if the appropriate
# sections were found in the config file, so we do nothing if the
# config has a loggers section, otherwise we do some simple setup
# using the 'log_*' values from the config.
if config.global_conf_parser.has_section( "loggers" ):
return
format = config.get( "log_format", "%(name)s %(levelname)s %(asctime)s %(message)s" )
level = logging._levelNames[ config.get( "log_level", "DEBUG" ) ]
destination = config.get( "log_destination", "stdout" )
log.info( "Logging at '%s' level to '%s'" % ( level, destination ) )
# Get root logger
root = logging.getLogger()
# Set level
root.setLevel( level )
# Turn down paste httpserver logging
if level <= logging.DEBUG:
logging.getLogger( "paste.httpserver.ThreadPool" ).setLevel( logging.WARN )
# Remove old handlers
for h in root.handlers[:]:
root.removeHandler(h)
# Create handler
if destination == "stdout":
handler = logging.StreamHandler( sys.stdout )
else:
handler = logging.FileHandler( destination )
# Create formatter
formatter = logging.Formatter( format )
# Hook everything up
handler.setFormatter( formatter )
root.addHandler( handler )
# If sentry is configured, also log to it
if config.sentry_dsn:
from raven.handlers.logging import SentryHandler
sentry_handler = SentryHandler( config.sentry_dsn )
sentry_handler.setLevel( logging.WARN )
root.addHandler( sentry_handler )

0 comments on commit 2ebef64

Please sign in to comment.