create log file only if it doesn't exist
[sdnvpn.git] / sdnvpn / lib / logutil.py
1 #!/usr/bin/env python
2 #
3 # Copyright (c) 2018 All rights reserved
4 # This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 import logging
11 import os.path
12
13 from xtesting.core import feature
14
15
16 def getLogger(module_name):
17     logger = logging.getLogger(module_name)
18     log_file = "{}/{}.log".format("/var/lib/xtesting/results", "bgpvpn")
19     if not os.path.exists(log_file):
20         open(log_file, 'w+')
21     feature.Feature.configure_logger(logger, log_file)
22     return logger