opensourcehacker / sevabot

A Skype bot supporting integration with external services
http://sevabot-skype-bot.readthedocs.org/
565 stars 121 forks source link

Enabled per-module logging level settings #41

Open builtinnya opened 11 years ago

builtinnya commented 11 years ago

These changes make debugging modules easier.

builtinnya commented 11 years ago

I've also added a bug fix in disposing output of Skype. This bug creates a file named "1" in sevabot/

miohtama commented 11 years ago

Nice! I think we can make this little bit simpler.

Python has internal config file format to configure loggers:

http://docs.python.org/2/library/logging.config.html

We just create logging.conf which is read on the start up and "outsource" all logging configuration for it. It has more powerful syntax and people are more familiar with it, because the format is used in other applications too.

In fact we can rip off some existing logging configuration options from settings.py and just put into this file.

This reduces the amount of code we need to maintain ourselves.

Also, there is another trick:

  logger = logging.getLogger(__name__) # Takes logger name automatically from the module name

... useful for modules get renamed and shuffled around.

builtinnya commented 11 years ago

Outsourced all logging configurations to logging.conf.

These changes show just a simple way to do it.

Some design decisions and considerations:

miohtama commented 11 years ago

I think we can just ship with one logging.conf and set it to gitingore so users don't push this around.

settings.conf.example is with .example extension only because it contains a default password. Logging configuration does not have similar security risk, so we can happily have default logging.conf in place.

miohtama commented 11 years ago

Mmm... I just give it a thought regarding settings.py.example.

We could ship with settings.py. On startup, Sevabot reads the file. If there is a default password, it is changed to random string which is then printed to stderr and settings are reloaded. This way we can avoid unnecessary manual password set process and make the bot initial start up process streamlined. Some work though, and not very high priority.

builtinnya commented 11 years ago

I think .gitignore ignores only untracked files and making it work with tracked files isn't easy as https://gist.github.com/canton7/1423106 suggests.

builtinnya commented 11 years ago

Anyway we have to gitignore logging.conf :)