From: kaliko Date: Mon, 21 Oct 2013 17:15:28 +0000 (+0200) Subject: Enable file logging (cli and conf file X-Git-Tag: mpd-sima/0.12.0pr2~38 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=cf16a8a97327e008ccbd728b8c0eaf2e91c186c7;p=mpd-sima.git Enable file logging (cli and conf file --- diff --git a/doc/examples/all_settings.cfg b/doc/examples/all_settings.cfg index c08c1c9..31405fb 100644 --- a/doc/examples/all_settings.cfg +++ b/doc/examples/all_settings.cfg @@ -40,16 +40,26 @@ port = 6600 ######################## LOGGING FACILITY ############################# # [log] -# message are logged to console -# +## LOGFILE +# type: string (file path) +# description: file to log to. Usually used in daemon mode. +# default: logging to stdin/stdout +logfile = +## + ## VERBOSITY # type: string +# description: log verbosity +# Possible values: +# * debug, *DEBUG LEVEL MIGHT PRINT OUT YOUR PASSWORD* +# * info, default +# * warning +# * error # -# pick verbosity in : debug, info, warning, error -# default if not specify is "info" -# *DEBUG LEVEL MIGHT PRINT OUT YOUR PASSWORD* verbosity = info ## + + # ####################################################################### diff --git a/launch b/launch index f03ca5b..b769204 100755 --- a/launch +++ b/launch @@ -71,8 +71,9 @@ def main(): sopt = StartOpt(info) # set logger verbosity = sopt.options.get('verbosity', 'warning') + logfile = sopt.options.get('logfile', None) cli_loglevel = getattr(logging, verbosity.upper()) - set_logger(level=verbosity) + set_logger(level=verbosity, logfile=logfile) logger = logging.getLogger('sima') logger.setLevel(cli_loglevel) # loads configuration @@ -109,14 +110,18 @@ def main(): sima.shutdown() -# Script starts here -if __name__ == '__main__': +def run(): + """Catching broad exception + """ # pylint: disable=broad-except try: main() except Exception: exception_log() +# Script starts here +if __name__ == '__main__': + run() # VIM MODLINE # vim: ai ts=4 sw=4 sts=4 expandtab diff --git a/sima/plugins/lastfm.py b/sima/plugins/lastfm.py index 0bbddbd..935ddf8 100644 --- a/sima/plugins/lastfm.py +++ b/sima/plugins/lastfm.py @@ -73,7 +73,6 @@ class Lastfm(Plugin): def _cleanup_cache(self): """Avoid bloated cache """ - # TODO: call cleanup once its dict instance are used somewhere XXX for _ , val in self._cache.items(): if isinstance(val, dict): while len(val) > 150: @@ -238,7 +237,7 @@ class Lastfm(Plugin): self.log.debug('Trying to find titles to add for "{}"'.format( artist)) found = self.player.find_track(artist) - # find tracks not in history + # find tracks not in history for artist self.filter_track(found) if len(self.to_add) == nbtracks_target: break diff --git a/sima/utils/config.py b/sima/utils/config.py index 5d79e53..15c1a3d 100644 --- a/sima/utils/config.py +++ b/sima/utils/config.py @@ -54,10 +54,13 @@ DEFAULT_CONF = { 'pidfile': "",}, 'log': { 'verbosity': "info", - 'logfile': "",}, + 'logfile': "", + }, + 'echonest': { + }, 'lastfm': { 'dynamic': "10", - 'similarity': "20", + 'similarity': "15", 'queue_mode': "track", #TODO control values 'single_album': "false", 'track_to_add': "1", @@ -115,11 +118,11 @@ class ConfMan(object): # CONFIG MANAGER CLASS return None except ValueError: # ValueError if password not a boolean, hence an actual password. - pw = self.config.get('MPD', 'password') - if not pw: + pwd = self.config.get('MPD', 'password') + if not pwd: self.log.debug('Password set as an empty string.') return None - return pw + return pwd def control_mod(self): """