added new option for log file
This commit is contained in:
parent
feb4e4ac88
commit
c005c31afa
14
transwhat.py
14
transwhat.py
|
@ -43,6 +43,7 @@ from yowsup.stacks import YowStack
|
||||||
# Arguments
|
# Arguments
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--debug', action='store_true')
|
parser.add_argument('--debug', action='store_true')
|
||||||
|
parser.add_argument('--log', type=str)
|
||||||
parser.add_argument('--host', type=str, required=True)
|
parser.add_argument('--host', type=str, required=True)
|
||||||
parser.add_argument('--port', type=int, required=True)
|
parser.add_argument('--port', type=int, required=True)
|
||||||
parser.add_argument('--service.backend_id', metavar="ID", 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()
|
args, unknown = parser.parse_known_args()
|
||||||
|
|
||||||
YowConstants.PATH_STORAGE='/var/lib/spectrum2/' + args.j
|
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
|
||||||
logging.basicConfig( \
|
logging.basicConfig(
|
||||||
filename=loggingfile,\
|
filename=args.log,
|
||||||
format = "%(asctime)-15s %(levelname)s %(name)s: %(message)s", \
|
format = "%(asctime)-15s %(levelname)s %(name)s: %(message)s",
|
||||||
level = logging.DEBUG if args.debug else logging.INFO \
|
level = logging.DEBUG if args.debug else logging.INFO
|
||||||
)
|
)
|
||||||
|
|
||||||
# Handler
|
# Handler
|
||||||
|
|
Loading…
Reference in a new issue