added new option for log file

This commit is contained in:
Steffen Vogel 2016-04-06 21:10:04 +02:00
parent feb4e4ac88
commit c005c31afa
2 changed files with 10 additions and 6 deletions

View file

@ -43,6 +43,7 @@ from yowsup.stacks import YowStack
# Arguments
parser = argparse.ArgumentParser()
parser.add_argument('--debug', action='store_true')
parser.add_argument('--log', type=str)
parser.add_argument('--host', type=str, required=True)
parser.add_argument('--port', type=int, required=True)
parser.add_argument('--service.backend_id', metavar="ID", type=int, required=True)
@ -52,12 +53,15 @@ parser.add_argument('-j', type=str, required=True)
args, unknown = parser.parse_known_args()
YowConstants.PATH_STORAGE='/var/lib/spectrum2/' + args.j
loggingfile = '/var/log/spectrum2/' + args.j + '/backends/backend.log'
if args.log is None:
args.log = '/var/log/spectrum2/' + args.j + '/backends/backend.log'
# Logging
logging.basicConfig( \
filename=loggingfile,\
format = "%(asctime)-15s %(levelname)s %(name)s: %(message)s", \
level = logging.DEBUG if args.debug else logging.INFO \
logging.basicConfig(
filename=args.log,
format = "%(asctime)-15s %(levelname)s %(name)s: %(message)s",
level = logging.DEBUG if args.debug else logging.INFO
)
# Handler

View file

@ -50,4 +50,4 @@ def decodePassword(password):
return base64.b64decode(bytes(password.encode("utf-8")))
def sha1hash(data):
return hashlib.sha1(data).hexdigest()
return hashlib.sha1(data).hexdigest()