Skip to content

Commit

Permalink
Add --verbose option.
Browse files Browse the repository at this point in the history
  • Loading branch information
nehpetsde committed May 19, 2018
1 parent a39f394 commit def3c33
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/nfc/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import os
import errno
import logging
import platform
import argparse
import subprocess
Expand All @@ -46,6 +47,11 @@ def main(args):
(nfc.__version__, platform.python_version(), platform.platform()))
print("I'm now searching your system for contactless devices")

logging.basicConfig()
log_levels = (logging.WARN, logging.INFO, logging.DEBUG, logging.DEBUG-1)
log_level = log_levels[min(args.verbose, len(log_levels) - 1)]
logging.getLogger('nfc').setLevel(log_level)

found = 0
for vid, pid, bus, dev in nfc.clf.transport.USB.find("usb"):
if (vid, pid) in nfc.clf.device.usb_device_map:
Expand Down Expand Up @@ -201,4 +207,8 @@ def usb_device_found_is_busy(bus, dev, vid, pid, path):
"--search-tty", action="store_true",
help="do also search for serial devices on linux")

parser.add_argument(
"--verbose", "-v", action="count", default=0,
help="be verbose. Multiple -v options increase the verbosity.")

main(parser.parse_args())

0 comments on commit def3c33

Please sign in to comment.