[email protected] wrote:

> Author: tomaz
> Date: Tue Jun 21 12:20:23 2011
> New Revision: 1137972
> 
> URL: http://svn.apache.org/viewvc?rev=1137972&view=rev
> Log:
> Allow user to set the debug log file path using the environment variable.

What is the reasoning behind this change? 

Before this change, user could say say something like

$ LIBCLOUD_DEBUG=1 ./some_libcloud_using_script.py

and debugging will go to /tmp/libcloud_debug.log

If that location doesn't suit user, she could go with

$ LIBCLOUD_DEBUG=~/mylibcloud.log ./some_libcloud_using_script.py

The committed change forces you to use two environment variables instead
of one to specify path to log file, which is a bit cumbersome (not to
mention that it breaks old behaviour which a number of people are used
to I believe).

> Modified:
>     libcloud/trunk/libcloud/__init__.py
> 
> Modified: libcloud/trunk/libcloud/__init__.py
> URL: 
> http://svn.apache.org/viewvc/libcloud/trunk/libcloud/__init__.py?rev=1137972&r1=1137971&r2=1137972&view=diff
> ==============================================================================
> --- libcloud/trunk/libcloud/__init__.py (original)
> +++ libcloud/trunk/libcloud/__init__.py Tue Jun 21 12:20:23 2011
> @@ -20,8 +20,10 @@ libcloud provides a unified interface to
>  """
>  
>  __all__ = ["__version__", "enable_debug"]
> +__version__ = '0.5.1'
> +
> +DEFAULT_LOG_PATH = '/tmp/libcloud_debug.log'
>  
> -__version__ = "0.5.1"
>  
>  def enable_debug(fo):
>      """
> @@ -35,7 +37,9 @@ def enable_debug(fo):
>                                 LoggingHTTPSConnection)
>      LoggingHTTPSConnection.log = fo
>      LoggingHTTPConnection.log = fo
> -    ConnectionKey.conn_classes = (LoggingHTTPConnection, 
> LoggingHTTPSConnection)
> +    ConnectionKey.conn_classes = (LoggingHTTPConnection,
> +                                  LoggingHTTPSConnection)
> +
>  
>  def _init_once():
>      """
> @@ -48,11 +52,10 @@ def _init_once():
>      default.
>      """
>      import os
> -    d = os.getenv("LIBCLOUD_DEBUG")
> -    if d:
> -        if d.isdigit():
> -            d = "/tmp/libcloud_debug.log"
> -        fo = open(d, "a")
> -        enable_debug(fo)
> +    if 'LIBCLOUD_DEBUG' in os.environ:
> +        debug_file_path = os.environ.get('LIBCLOUD_DEBUG_PATH') or \
> +                          DEFAULT_LOG_PATH
> +        fh = open(debug_file_path, 'a')
> +        enable_debug(fh)
>  
>  _init_once()
> 
> 

Roman Bogorodskiy

Reply via email to