Skip to content

Commit

Permalink
Correct logging configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Nov 16, 2023
1 parent 28fd50e commit 8ef0269
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions addon_meterstoha/rootfs/haevent2exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import functools
import json
import logging
import os
import time
from collections import defaultdict

Expand Down Expand Up @@ -174,9 +175,12 @@ async def execute_external(


async def main():
logging.basicConfig(
format="%(asctime)s %(message)s", datefmt="[%Y/%m/%d %H:%M:%S]"
)
PROGRAM = os.path.basename(__file__)
logConfig = {
"format": f"%(asctime)s ({PROGRAM}) %(levelname)-7s %(message)s",
"datefmt": "[%Y/%m/%d %H:%M:%S]",
}
logging.basicConfig(force=True, **logConfig)

parser = argparse.ArgumentParser(
description="Home Assistant Event Listener"
Expand Down Expand Up @@ -204,7 +208,8 @@ async def main():

args = parser.parse_args()

logging.basicConfig(level=args.log_level.upper())
logConfig["level"] = args.log_level.upper()
logging.basicConfig(force=True, **logConfig)
event_filter = args.events
external_program = args.external_program
execution_timeout = args.timeout
Expand Down

0 comments on commit 8ef0269

Please sign in to comment.