mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 11:18:03 +00:00
cisco_wifi_ctl.py : added the ability to append logging to an existing file
This was needed since lf_cisco_power.py and other files that use cisco_wifi_ctl.py will need to pass in a log file.
This commit is contained in:
@@ -99,6 +99,7 @@ def main():
|
||||
parser.add_argument("-s", "--scheme", type=str, choices=["serial", "ssh", "telnet"], help="Connect via serial, ssh or telnet")
|
||||
parser.add_argument("-t", "--tty", type=str, help="tty serial device")
|
||||
parser.add_argument("-l", "--log", type=str, help="logfile for messages, stdout means output to console",default="stdout")
|
||||
parser.add_argument("--append", action='store_true', help="--append append to logfile file")
|
||||
#parser.add_argument("-r", "--radio", type=str, help="select radio")
|
||||
parser.add_argument("-w", "--wlan", type=str, help="wlan name")
|
||||
parser.add_argument("-i", "--wlanID", type=str, help="wlan ID")
|
||||
@@ -124,6 +125,7 @@ def main():
|
||||
user = args.user
|
||||
passwd = args.passwd
|
||||
logfile = args.log
|
||||
append = args.append
|
||||
if (args.band != None):
|
||||
band = args.band
|
||||
if (band == "abgn"):
|
||||
@@ -141,11 +143,14 @@ def main():
|
||||
file_handler = None
|
||||
if (logfile is not None):
|
||||
if (logfile != "stdout"):
|
||||
file_handler = logging.FileHandler(logfile, "w")
|
||||
if append:
|
||||
file_handler = logging.FileHandler(logfile, "a")
|
||||
else:
|
||||
file_handler = logging.FileHandler(logfile, "w")
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
file_handler.setFormatter(formatter)
|
||||
logg.addHandler(file_handler)
|
||||
logging.basicConfig(format=FORMAT, handlers=[file_handler])
|
||||
logg.addHandler(logging.StreamHandler(sys.stdout))
|
||||
else:
|
||||
# stdout logging
|
||||
logging.basicConfig(format=FORMAT, handlers=[console_handler])
|
||||
|
||||
Reference in New Issue
Block a user