|
1 | 1 | #!/usr/bin/env python3 |
2 | | - |
3 | 2 | from asyncio import get_event_loop, gather |
4 | 3 | from collections import defaultdict |
5 | 4 | from datetime import datetime |
6 | 5 | from json import dumps |
| 6 | +from logging import getLogger, basicConfig, INFO |
7 | 7 | from os import environ |
8 | 8 | from pathlib import Path |
9 | 9 | from random import choice |
|
32 | 32 |
|
33 | 33 | filterwarnings("ignore", category=InsecureRequestWarning) |
34 | 34 |
|
| 35 | +logger = getLogger(__name__) |
| 36 | + |
| 37 | +# TODO: opt to change log-level |
| 38 | +basicConfig(format="%(message)s", level=INFO) |
| 39 | + |
35 | 40 |
|
36 | 41 | def bucket_exists(url, timeout): |
37 | 42 | exists = False |
@@ -60,7 +65,7 @@ def find_bucket(url, timeout): |
60 | 65 | if exists: |
61 | 66 | access = public_key if public else private_key |
62 | 67 | access_word = public_text if public else private_text |
63 | | - print(f"{access} {access_word} {url}", end="\n") |
| 68 | + logger.info(f"{access} {access_word} {url}") |
64 | 69 | return access, url |
65 | 70 |
|
66 | 71 | return None |
@@ -88,7 +93,6 @@ def read_config(): |
88 | 93 |
|
89 | 94 | for c in config_hierarchy: |
90 | 95 | try: |
91 | | - print(c) |
92 | 96 | c = load(open(c, "r")) |
93 | 97 | merge(config, c) |
94 | 98 | except IOError: |
@@ -123,8 +127,8 @@ def main(words, timeout, output): |
123 | 127 | private, public = collect_results(r) |
124 | 128 | stop = datetime.now() |
125 | 129 |
|
126 | | - print(f"Complete after: {stop - start}") |
127 | | - print(f"Output written to: {output.name}") |
| 130 | + logger.info(f"Complete after: {stop - start}") |
| 131 | + logger.info(f"Output written to: {output.name}") |
128 | 132 |
|
129 | 133 | output.write( |
130 | 134 | dumps( |
|
0 commit comments