mickael9 committed 8d00cd5

Better logging

Comments (0)

Files changed (2)

         resp = urlopen(req)
+        logger.debug("got %d response", resp.status)
         raw =
     except HTTPError as ex:
         resp = ex
+        logger.debug("got %d error", resp.code) # urllib sucks
         raw =
     raw = raw.decode('utf-8')
         print("Error: unable to decode JSON: %s" % raw)
         raise APIError("Unable to decode JSON: %s", raw)
-    logger.debug("response (%d):\n%s", resp.status, pprint.pformat(result))
+    logger.debug("json:\n%s", pprint.pformat(result))
     if 'error' in result:
         raise APIError(result['error'])
     except APIError as ex:
-        print('API error: %s' % ex)
+        logger.error('API error: %s', ex)
 def pattern(string):
     import glob
                 ret.append(open(item, 'rb'))
     if not ret:
-        print('warning: %s: no match' % string)
+        logger.warning('%s: no match', string)
     return ret
 def main():
             user.login_auth(, args.password)
-        except Exception as ex:
-            print('Unable to login: %s' % ex.args[0])
+        except APIError as ex:
+            logger.error('Unable to login: %s', ex)
         reply = input('Do you wish to store the session token? (y/n): ')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.