@@ -88,8 +88,7 @@ def get_command(self, ctx, name):
8888 help = "Config file location" ,
8989 type = click .Path (resolve_path = True ))
9090@click .option ('--verbose' , '-v' ,
91- help = "Sets the debug noise level, specify multiple times "
92- "for more verbosity." ,
91+ help = "Sets the debug noise level, specify multiple times for more verbosity." ,
9392 type = click .IntRange (0 , 3 , clamp = True ),
9493 count = True )
9594@click .option ('--proxy' ,
@@ -115,10 +114,9 @@ def cli(env,
115114 ** kwargs ):
116115 """Main click CLI entry-point."""
117116
118- if verbose > 0 :
119- logger = logging .getLogger ()
120- logger .addHandler (logging .StreamHandler ())
121- logger .setLevel (DEBUG_LOGGING_MAP .get (verbose , logging .DEBUG ))
117+ logger = logging .getLogger ()
118+ logger .addHandler (logging .StreamHandler ())
119+ logger .setLevel (DEBUG_LOGGING_MAP .get (verbose , logging .DEBUG ))
122120
123121 # Populate environement with client and set it as the context object
124122 env .skip_confirmations = really
@@ -127,7 +125,7 @@ def cli(env,
127125 env .ensure_client (config_file = config , is_demo = demo , proxy = proxy )
128126
129127 env .vars ['_start' ] = time .time ()
130- env .vars ['_timings' ] = SoftLayer .TimingTransport (env .client .transport )
128+ env .vars ['_timings' ] = SoftLayer .DebugTransport (env .client .transport )
131129 env .client .transport = env .vars ['_timings' ]
132130
133131
@@ -138,22 +136,37 @@ def output_diagnostics(env, verbose=0, **kwargs):
138136
139137 if verbose > 0 :
140138 diagnostic_table = formatting .Table (['name' , 'value' ])
141- diagnostic_table .add_row (['execution_time' ,
142- '%fs' % (time .time () - START_TIME )])
139+ diagnostic_table .add_row (['execution_time' , '%fs' % (time .time () - START_TIME )])
143140
144141 api_call_value = []
145- for call , _ , duration in env .vars ['_timings' ].get_last_calls ():
146- api_call_value .append (
147- "%s::%s (%fs)" % (call .service , call .method , duration ))
142+ for call in env .client .transport .get_last_calls ():
143+ api_call_value .append ("%s::%s (%fs)" % (call .service , call .method , call .end_time - call .start_time ))
148144
149145 diagnostic_table .add_row (['api_calls' , api_call_value ])
150146 diagnostic_table .add_row (['version' , consts .USER_AGENT ])
151147 diagnostic_table .add_row (['python_version' , sys .version ])
152- diagnostic_table .add_row (['library_location' ,
153- os .path .dirname (SoftLayer .__file__ )])
148+ diagnostic_table .add_row (['library_location' , os .path .dirname (SoftLayer .__file__ )])
154149
155150 env .err (env .fmt (diagnostic_table ))
156151
152+ if verbose > 1 :
153+ for call in env .client .transport .get_last_calls ():
154+ call_table = formatting .Table (['' , '{}::{}' .format (call .service , call .method )])
155+ nice_mask = ''
156+ if call .mask is not None :
157+ nice_mask = call .mask
158+
159+ call_table .add_row (['id' , call .identifier ])
160+ call_table .add_row (['mask' , nice_mask ])
161+ call_table .add_row (['filter' , call .filter ])
162+ call_table .add_row (['limit' , call .limit ])
163+ call_table .add_row (['offset' , call .offset ])
164+ env .err (env .fmt (call_table ))
165+
166+ if verbose > 2 :
167+ for call in env .client .transport .get_last_calls ():
168+ env .err (env .client .transport .print_reproduceable (call ))
169+
157170
158171def main (reraise_exceptions = False , ** kwargs ):
159172 """Main program. Catches several common errors and displays them nicely."""
@@ -163,8 +176,7 @@ def main(reraise_exceptions=False, **kwargs):
163176 cli .main (** kwargs )
164177 except SoftLayer .SoftLayerAPIError as ex :
165178 if 'invalid api token' in ex .faultString .lower ():
166- print ("Authentication Failed: To update your credentials,"
167- " use 'slcli config setup'" )
179+ print ("Authentication Failed: To update your credentials, use 'slcli config setup'" )
168180 exit_status = 1
169181 else :
170182 print (str (ex ))
@@ -184,6 +196,7 @@ def main(reraise_exceptions=False, **kwargs):
184196 print (str (traceback .format_exc ()))
185197 print ("Feel free to report this error as it is likely a bug:" )
186198 print (" https://github.com/softlayer/softlayer-python/issues" )
199+ print ("The following snippet should be able to reproduce the error" )
187200 exit_status = 1
188201
189202 sys .exit (exit_status )
0 commit comments