better NAT logging

This commit is contained in:
Hugo Levy-Falk 2019-05-06 23:45:44 +02:00 committed by root
parent 100942fb90
commit 3a4b8969c6

5
nat.py
View file

@ -95,7 +95,10 @@ def main():
nat_log += aloes_nat.manage() nat_log += aloes_nat.manage()
logging.info("Done.") logging.info("Done.")
filename = "/var/log/nat-%s.log" % ctime nat_directory = "/var/log/nat/"
if not os.path.exists(nat_directory):
os.makedirs(nat_directory)
filename = os.path.join(nat_directory, "nat_%s.log" % time.strftime('%Y_%m_%d_%Hh_%Mm'))
logging.info("Saving nat table into " + filename) logging.info("Saving nat table into " + filename)
with open(filename, 'a') as f: with open(filename, 'a') as f: