]> kaliko git repositories - mpd-sima.git/commitdiff
Enable file logging (cli and conf file
authorkaliko <efrim@azylum.org>
Mon, 21 Oct 2013 17:15:28 +0000 (19:15 +0200)
committerkaliko <efrim@azylum.org>
Mon, 21 Oct 2013 17:15:28 +0000 (19:15 +0200)
doc/examples/all_settings.cfg
launch
sima/plugins/lastfm.py
sima/utils/config.py

index c08c1c9f303bb26c6090e56dfaed0374d96317e9..31405fb3b899a805432f7fdcc25e266254815a94 100644 (file)
@@ -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 f03ca5b120fcc753dc6035914bef19f8aa0ccd22..b769204e37371b932218050ca0a8069d7e4becb6 100755 (executable)
--- 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
index 0bbddbd33f0e8ae8b767692877a1cdc0fb8e1715..935ddf8223e0288225744f1ea50afcc9202340e4 100644 (file)
@@ -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
index 5d79e53a2bbcee6dc34f6fd477f7b79e921f61bf..15c1a3dd2ca8c54f5d5769d5bf5fcabac7fc3167 100644 (file)
@@ -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):
         """