Closed ghost closed 5 years ago
I agree, i'll leave you to add that in, I can make changes to this PR if needed to support a different logging level. In the long run, I think a UI element to control the log level would be useful! Perhaps also mirror the log to a file so there is no need to manually start the app to see the logs. Not the case with docker though!
@cheesemarathon this is opened for 11 days, if is working let's merge it.
Sorry Marius been away for a bit, will just double check it's all ok then merge it now
@cheesemarathon i have an update that print to STDOUT just info messages. I will push it soon. I'm thinking to change the condition in header instead of if debug:
to made it if debug or docker:
so in container will output the info messages by default.
I am not sure how this is working for you. If I do not set $MAC and $IP environment variables for my docker image, and set only the $DEBUG environment variable, then inside startup.sh, $1 has the value of DEBUG and $2 and $3 do not exist at all.
Larger question: why do we need the startup.sh file at all? Why can't we just put its functionality in the HueEmulator3.py and execute it directly from the Dockerfile?
@t-anjan It won't work if you don't set $1, $2, and $3 as MAC, IP and DEBUG respectively. The code is very simple and expects you to provide all args in that specific order. However, I hadn't considered people not wanting to set MAC and IP but needing to set MAC so this clearly needs a fix.
As for moving its function into HueEmulator3.py. Seems like a smart idea, I had just never thought about it. No real reason as far as I'm concerned. I'll look into it.
@mariusmotea I think perhaps we should combine our efforts. We should move the function of startup.sh into HueEmulator.py and add your STDOUT update in. This would have the added benefit of users that don't use docker being able to run the emulator with arguments. Aka debug could be enabled by stopping the service and running with python HueEmulator3.py debug=true
for example
Great! 👍
Using argparse in python, it would be even cleaner to incorporate arguments.
Exactly what I'm currently looking at @t-anjan
@mariusmotea are we no longer using the $ip argument in HueEmulator3.py? Currently, in the Docker container, the user entered IP is passed to HueEmulator3.py as the second arg, however, I don't see it used anywhere. Are we just always using the get getIpAddress() function now? If that's the case, we can then get rid of IP arg. Just read getIpAddress()
and it uses the parsed argument if supplied
i believe we should create new logging level because debug output too much from requests.packages.urllib3.