Compare commits

...

2 commits

Author SHA1 Message Date
Patrick Moessler
cdf8686a79 improve log 2023-06-13 10:49:55 +02:00
Patrick Moessler
9a7a9b96a1 use log write instead of print 2023-06-13 10:45:03 +02:00

View file

@ -83,7 +83,7 @@ class State:
return None return None
async def handle_key(self, key_num: int, state: bool) -> str | None: async def handle_key(self, key_num: int, state: bool) -> str | None:
print(f"key:{key_num}, state:{state}") log.debug(f"key:{key_num}, state:{state}")
if state is True: if state is True:
msg = { msg = {
"apiVersion": "1.0.0", "apiVersion": "1.0.0",
@ -213,7 +213,7 @@ class TeamsCtrl:
if key_num > 4 or key_num < 0: if key_num > 4 or key_num < 0:
raise IndexError("invalid key number: {key_num}") raise IndexError("invalid key number: {key_num}")
cmd = f"{key_num:01}{color[0]:02x}{color[1]:02x}{color[2]:02x}\n" cmd = f"{key_num:01}{color[0]:02x}{color[1]:02x}{color[2]:02x}\n"
print(cmd) log.debug(f"set color:{cmd.strip()}")
self.serial_writer.write(cmd.encode("utf-8")) self.serial_writer.write(cmd.encode("utf-8"))
async def process_serial(self) -> None: async def process_serial(self) -> None:
@ -313,6 +313,11 @@ if __name__ == "__main__":
) )
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=args.log)
if args.log == "DEBUG":
logging.getLogger("asyncio").setLevel(logging.INFO)
logging.getLogger("websockets.client").setLevel(logging.INFO)
with open(args.token) as tf: with open(args.token) as tf:
token = tf.read().strip() token = tf.read().strip()