[Kimchi-devel] [PATCH] Disabling screen log in production environment

Aline Manera alinefm at linux.vnet.ibm.com
Wed Oct 15 17:32:57 UTC 2014


On 10/14/2014 05:11 PM, Daniel Henrique Barboza wrote:
> When building kimchi's RPM, some messages are getting
> logged in /var/log/messages because cherrypy is logging
> in the standard output. This happens because a function
> in FeatureTests is enabling log.screen regardless of the
> current environment. This patch makes a verification that
> prevents the screen log to be enabled in the production
> environment.
>
> The line 'cherrypy.log.screen = True' was removed in
> server.py because it has no effect. It is ignored in the
> default (=production) environment

Why is it ignored? AFAIK the production environment only sets different 
error handlers.

> and it is redundant in
> dev environment because the screen log is activated by
> default.
>
> Signed-off-by: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
> ---
>   src/kimchi/featuretests.py | 6 ++++--
>   src/kimchi/server.py       | 1 -
>   2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py
> index c6f4687..1310745 100644
> --- a/src/kimchi/featuretests.py
> +++ b/src/kimchi/featuretests.py
> @@ -95,8 +95,10 @@ class FeatureTests(object):
>       def enable_screen_error_logging():
>           # Unregister the error handler
>           libvirt.registerErrorHandler(f=None, ctx=None)
> -        # Enable cherrypy screen logging
> -        cherrypy.log.screen = True
> +        # Enable cherrypy screen logging if running environment
> +        # is not 'production'
> +        if cherrypy.config.get('environment') != 'production':
> +            cherrypy.log.screen = True

As we will enable cherrypy.log.screen only for "development" environment 
we can remove the
cherrypy.log.screen assignment on featuretests.py

That way we will log everything on development environment that can 
helps debug.

>       @staticmethod
>       def libvirt_supports_iso_stream(protocol):
> diff --git a/src/kimchi/server.py b/src/kimchi/server.py
> index 8d166e5..46f128c 100644
> --- a/src/kimchi/server.py
> +++ b/src/kimchi/server.py
> @@ -91,7 +91,6 @@ class Server(object):
>           max_body_size_in_bytes = eval(options.max_body_size) * 1024
>           cherrypy.server.max_request_body_size = max_body_size_in_bytes

> -        cherrypy.log.screen = True

You need to check the environment is development and set 
cherrypy.log.screen = True

>           cherrypy.log.access_file = options.access_log
>           cherrypy.log.error_file = options.error_log
>




More information about the Kimchi-devel mailing list