switch verbosity level via command line
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
# virtualsmartcard. If not, see <http://www.gnu.org/licenses/>.
|
# virtualsmartcard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
import argparse
|
import argparse, logging
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@@ -38,6 +38,9 @@ parser.add_argument("-t", "--type",
|
|||||||
choices=['iso7816', 'cryptoflex', 'ePass', 'nPA', 'relay', 'handler_test'],
|
choices=['iso7816', 'cryptoflex', 'ePass', 'nPA', 'relay', 'handler_test'],
|
||||||
default='iso7816',
|
default='iso7816',
|
||||||
help="type of smart card to emulate (default: %(default)s)")
|
help="type of smart card to emulate (default: %(default)s)")
|
||||||
|
parser.add_argument("-v", "--verbose",
|
||||||
|
action="count",
|
||||||
|
help="Use (several times) to be more verbose")
|
||||||
parser.add_argument("-f", "--file",
|
parser.add_argument("-f", "--file",
|
||||||
action="store",
|
action="store",
|
||||||
type=argparse.FileType('r'),
|
type=argparse.FileType('r'),
|
||||||
@@ -104,8 +107,19 @@ if (args.cvca):
|
|||||||
cvca = args.cvca.read()
|
cvca = args.cvca.read()
|
||||||
args.cvca.close()
|
args.cvca.close()
|
||||||
|
|
||||||
|
if not args.verbose:
|
||||||
|
logginglevel = logging.CRITICAL
|
||||||
|
elif args.verbose == 1:
|
||||||
|
logginglevel = logging.ERROR
|
||||||
|
elif args.verbose == 2:
|
||||||
|
logginglevel = logging.WARNING
|
||||||
|
elif args.verbose == 3:
|
||||||
|
logginglevel = logging.INFO
|
||||||
|
else:
|
||||||
|
logginglevel = logging.DEBUG
|
||||||
|
|
||||||
vicc = VirtualICC(args.file, args.type,
|
vicc = VirtualICC(args.file, args.type,
|
||||||
args.hostname, args.port, readernum=args.reader,
|
args.hostname, args.port, readernum=args.reader,
|
||||||
ef_cardaccess=ef_cardaccess_data, ef_cardsecurity=ef_cardsecurity_data,
|
ef_cardaccess=ef_cardaccess_data, ef_cardsecurity=ef_cardsecurity_data,
|
||||||
ca_key=ca_key_data, cvca=cvca, disable_checks=args.disable_ta_checks)
|
ca_key=ca_key_data, cvca=cvca, disable_checks=args.disable_ta_checks, logginglevel=logginglevel)
|
||||||
vicc.run()
|
vicc.run()
|
||||||
|
|||||||
@@ -622,10 +622,10 @@ class VirtualICC(object):
|
|||||||
the vpcd, which forwards it to the application.
|
the vpcd, which forwards it to the application.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, filename, card_type, host, port, lenlen=3, readernum=None, ef_cardsecurity=None, ef_cardaccess=None, ca_key=None, cvca=None, disable_checks=False):
|
def __init__(self, filename, card_type, host, port, lenlen=3, readernum=None, ef_cardsecurity=None, ef_cardaccess=None, ca_key=None, cvca=None, disable_checks=False, logginglevel=logging.INFO):
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
|
|
||||||
logging.basicConfig(level = logging.INFO,
|
logging.basicConfig(level = logginglevel,
|
||||||
format = "%(asctime)s [%(levelname)s] %(message)s",
|
format = "%(asctime)s [%(levelname)s] %(message)s",
|
||||||
datefmt = "%d.%m.%Y %H:%M:%S")
|
datefmt = "%d.%m.%Y %H:%M:%S")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user