Move util.debug and util.log_error to logging module
[time-slider.git] / usr / share / time-slider / lib / time_slider / util.py
index a9930e0..496b686 100644 (file)
@@ -27,6 +27,7 @@ import syslog
 import statvfs
 import math
 import gio
+import logging
 
 def run_command(command, raise_on_try=True):
     """
@@ -35,6 +36,8 @@ def run_command(command, raise_on_try=True):
     Throws a RunTimeError if the command failed to execute or
     if the command returns a non-zero exit status.
     """
+
+    debug("Trying to run command %s" % (command), True)
     try:
         p = subprocess.Popen(command,
                              stdout=subprocess.PIPE,
@@ -58,8 +61,7 @@ def debug(message, verbose):
     context using syslog.openlog()
     """
     if verbose:
-        syslog.syslog(syslog.LOG_NOTICE, message + '\n')
-        sys.stderr.write(message + '\n')
+        logging.getLogger('time-slider').debug(message)
 
 def log_error(loglevel, message):
     """
@@ -67,8 +69,7 @@ def log_error(loglevel, message):
     Requires caller to have first opened a syslog session
     using syslog.openlog()
     """
-    syslog.syslog(loglevel, message + '\n')
-    sys.stderr.write(message + '\n')
+    logging.getLogger('time-slider').error(message)
 
 def get_filesystem_capacity(path):
     """Returns filesystem space usage of path as an integer percentage of