Skip to content

Commit

Permalink
refactor: check 'n create logdir if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
qaldak committed Mar 7, 2023
1 parent 0252ac2 commit b23c8a1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import logging
import os

from src.check_container import Container
from src.get_hostname import get_hostname
Expand Down Expand Up @@ -36,7 +37,11 @@ def main(receiver_ip, reset_unbound_stats: bool):
help="Set loglevel to DEBUG")
args = parser.parse_args()

logging.basicConfig(level=args.loglevel, filename="log/unbound-stats.log",
logdir = "log"
if not os.path.isdir(logdir):
os.makedirs(logdir)

logging.basicConfig(level=args.loglevel, filename=f"{logdir}/unbound-stats.log",
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

main(args.receiver_ip, args.reset_unbound_stats)

0 comments on commit b23c8a1

Please sign in to comment.