Skip to content

Commit

Permalink
configurable logging stream
Browse files Browse the repository at this point in the history
  • Loading branch information
SupraSummus committed Mar 31, 2018
1 parent a8eaaa9 commit 2f82d60
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pgspawn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ from pgspawn import PipeGraphSpawner, Graph, GraphException


parser = argparse.ArgumentParser(description="Spawn graph of streaming commands.")
parser.add_argument("file", type=open, help="file containing graph description")
parser.add_argument("file", type=argparse.FileType('r'), help="file containing graph description")
parser.add_argument(
"-l", "--log",
dest='log', default=sys.stderr, type=argparse.FileType('w'),
help="where to put logs, use something like /proc/self/fd/5 for logging to custom fd",
)
parser.add_argument(
"-v", "--verbose",
dest='verbose_count', action='count', default=0,
Expand All @@ -26,6 +31,7 @@ if __name__ == '__main__':
logging.basicConfig(
format='%(process)d %(levelname)s: %(message)s',
level=max(3 - arguments.verbose_count, 0) * 10,
stream=arguments.log,
)

logging.debug("Hi, this is pgspawn speaking. Running with commandline {}.".format(sys.argv))
Expand Down

0 comments on commit 2f82d60

Please sign in to comment.