Skip to content

Instantly share code, notes, and snippets.

@peregrinogris
Created November 30, 2011 17:47
Show Gist options
  • Save peregrinogris/1409994 to your computer and use it in GitHub Desktop.
Save peregrinogris/1409994 to your computer and use it in GitHub Desktop.
Extra simple remote logger
#!/usr/bin/python
from bottle import route, run, debug
import argparse
parser = argparse.ArgumentParser(description='Really simple remote logger.')
parser.add_argument('-n', '--name', default="localhost", help="Name of the host from which the server will start (default: %(default)s)")
parser.add_argument('-p', '--port', default=1234, type=int, help="Port the server will be listening (default: %(default)s)")
args = parser.parse_args()
@route('/:msg')
def index(msg=''):
print msg
return ''
print "Listening on http://%s:%d" % (args.name, args.port)
run(quiet=True, host=args.name, port=args.port)
@peregrinogris
Copy link
Author

simpleLogger

Usage:

First start the server like this:

$ python simpleLogger.py -n [serverURL] -p [port]

If serverURL is omitted, the logger will start in localhost. The default port is 1234.

Then simply query the logger in this fashion:

http://[serverURL]:1234/[message]

The [message] part of the URL will be logged to your terminal.

The help can be invoked with:

$ python simpleParser.py -h

Note: This file can be set as executable and simply run as ./simpleLogger.py

Requirements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment