Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

loggly example: initial python implementation

  • Loading branch information...
commit c6cf03c1da954cf617707b74a7ad05e664118b29 1 parent 1ad06b7
@develop7 develop7 authored
Showing with 49 additions and 0 deletions.
  1. +19 −0 python/Loggly.py
  2. +30 −0 python/loggly/loggly.py
View
19 python/Loggly.py
@@ -0,0 +1,19 @@
+from ironworker import *
+import os
+import shutil
+
+import hoover
+
+#here we have to include hoover library with worker.
+worker_dir = os.path.dirname(__file__) + '/loggly'
+hoover_dir = os.path.dirname(hoover.__file__)
+shutil.copytree(hoover_dir, worker_dir + '/airbrakepy') #copy it to worker directory
+
+worker = IronWorker(config='config.ini')
+IronWorker.zipDirectory(directory=worker_dir, destination='loggly-py.zip', overwrite=True)
+
+res = worker.postCode(runFilename='loggly.py', zipFilename='loggly-py.zip', name='loggly-py')
+
+payload = {'loggly': {'subdomain': 'LOGGLY_SUBDOMAIN', 'username': 'LOGGLY_USERNAME', 'password': 'LOGGLY_PASSWORD'}}
+
+task = worker.postTask(name='loggly-py')
View
30 python/loggly/loggly.py
@@ -0,0 +1,30 @@
+import hoover
+import logging
+
+import argparse
+import json
+
+parser = argparse.ArgumentParser(
+ description="Some stuff")
+parser.add_argument("-payload", type=str, required=False,
+ help="The location of a file containing a JSON payload.")
+args = parser.parse_args()
+if args.payload is not None:
+ payload = json.loads(open(args.payload).read())
+ if 'loggly' in payload:
+ loggly_settings = payload['loggly']
+ i = hoover.LogglySession(loggly_settings['subdomain'], loggly_settings['username'], loggly_settings['password'])
+ i.config_inputs() #inject loggly handler into logger chain
+
+#and then usual yada-yada is going on
+logger = logging.getLogger('worker_log')
+
+# YOUR CODE HERE
+
+logger.debug("Debug message")
+
+#MORE CODE
+
+logger.warn('Warning message')
+
+logger.fatal('Unable to launch spaceship due to recent moon nazis invasion. Sorry for inconvenience.')
Please sign in to comment.
Something went wrong with that request. Please try again.