diff service/collector/sse_collector.py @ 693:be2fbdbdf549

collector: add /graphlist, plus logging updates Ignore-this: 6afc4f2573d9dd0d3299e7a676a723e7
author drewp@bigasterisk.com
date Wed, 29 Jan 2020 01:05:15 -0800
parents b1258d252ef0
children fe9cfc088a49
line wrap: on
line diff
--- a/service/collector/sse_collector.py	Wed Jan 29 01:04:09 2020 -0800
+++ b/service/collector/sse_collector.py	Wed Jan 29 01:05:15 2020 -0800
@@ -423,17 +423,22 @@
         except Exception:
             import traceback; traceback.print_exc()
             raise
-              
+
+class GraphList(cyclone.web.RequestHandler):
+    def get(self) -> None:
+        self.write(json.dumps(config['streams']))
+
 if __name__ == '__main__':
     arg = docopt("""
     Usage: sse_collector.py [options]
 
     -v   Verbose
+    -i  Info level only
     """)
-    
-    if arg['-v']:
+
+    if arg['-v'] or arg['-i']:
         enableTwistedLog()
-        log.setLevel(logging.DEBUG)
+        log.setLevel(logging.DEBUG if arg['-v'] else logging.INFO)
         defer.setDebugging(True)
 
 
@@ -448,7 +453,8 @@
                     "path": "static", "default_filename": "index.html"}),
                 (r'/static/(.*)',cyclone.web.StaticFileHandler, {"path": "static"}),
                 (r'/state', State),
-                (r'/graph/(.*)', PatchSink),
+                (r'/graph/', GraphList),
+                (r'/graph/(.+)', PatchSink),
                 (r'/stats/(.*)', StatsHandler, {'serverName': 'collector'}),
             ],
             graphClients=graphClients),