ironman5366 / W.I.L.L

A python written personal assistant
https://willbeddow.com
MIT License
377 stars 58 forks source link

Log handeling #3

Closed brenttaylor closed 8 years ago

brenttaylor commented 8 years ago

Is there a reason you're using your own logging functionality over the python supplied "logging" module? Should cut down your code significantly and it's more fault tolerant and less error prone.

I'd be happy to change it over. :)

ironman5366 commented 8 years ago

Mainly just because I REALLY like the look and style of my terminal logging. I'm fairly ignorant of the python builtin logging (having always used my own), could it be formatted with utilities like termcolor like mine is? And I also have two settings in mine that determine whether you want to keep logs or delete the old ones and whether you want to see terminal output or just a log file written. If this stuff can be replicated the sure, go for it.

brenttaylor commented 8 years ago

Everything but the color can be replicated. That said, the built in logging is a lot more robust and fault tolerant and we should really be using it. Generally speaking, if it's in the standard library you want to use it rather than rolling your own unless you have a very good reason to do otherwise.

I'll get started refactoring the logging code today.

ironman5366 commented 8 years ago

Yeah sure I guess. I am pretty partial to my terminal logging though, it's been a part of W.I.L.L for awhile. If you wouldn't mind going out of your way, can you get the log entry from the good builtin logging module and pass it through with termcolor like I've been doing?

brenttaylor commented 8 years ago

I'll look into it. That said, I'm personally partial to removing termcolor all together. It doesn't play well with everything, especially on windows. It's all sorts of odd in PowerShell, for example.

ironman5366 commented 8 years ago

Fair enough. I appreciate you working on it, thanks.

ironman5366 commented 8 years ago

Ok. So I merged in the code and I can't seem to fix the following error: Traceback (most recent call last): File "main.py", line 15, in <module> from logger import log File "/home/will/Code/W.I.L.L/logger.py", line 88, in <module> _setup_logger() File "/home/will/Code/W.I.L.L/logger.py", line 45, in _setup_logger log.setLevel(_get_logging_level()) File "/home/will/Code/W.I.L.L/logger.py", line 63, in _get_logging_level return logging.DEBUG if will_config["debug"] else logging.ERROR KeyError: 'debug' I looked through the code and I'm not completely sure what's happening here. My config.json is set up

ironman5366 commented 8 years ago

My mistake, I hadn't made the necessary changes to config.json. Closing

brenttaylor commented 8 years ago

That really should be considered a bug. I'll write up a new issue.