[Pkg-privacy-commits] [tails-installer] 27/43: Send all enabled logging output to the log file (in addition to stderr).

Ulrike Uhlig u-guest at moszumanska.debian.org
Tue Nov 15 23:30:22 UTC 2016


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to branch debian/sid
in repository tails-installer.

commit 41c10aae2aa68688ea628c7d55928b85c011bf3d
Author: intrigeri <intrigeri at boum.org>
Date:   Wed Jul 20 16:48:15 2016 +0000

    Send all enabled logging output to the log file (in addition to stderr).
    
    So far, the log file only got the output of our popen function.
---
 tails_installer/creator.py | 21 +++++++++++----------
 tails_installer/gui.py     |  2 +-
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/tails_installer/creator.py b/tails_installer/creator.py
index bf61cdd..d304897 100755
--- a/tails_installer/creator.py
+++ b/tails_installer/creator.py
@@ -99,8 +99,8 @@ class TailsInstallerCreator(object):
             if os.getuid() != 0:
                 print >> sys.stderr, _("You must run this application as root")
                 sys.exit(1)
-        self._setup_logger()
         self._error_log_filename = self._setup_error_log_file()
+        self._setup_logger()
 
     def _setup_error_log_file(self):
         temp = tempfile.NamedTemporaryFile(mode='a', delete=False,
@@ -111,10 +111,16 @@ class TailsInstallerCreator(object):
     def _setup_logger(self):
         self.log = logging.getLogger()
         self.log.setLevel(logging.DEBUG if self.opts.verbose else logging.INFO)
-        self.handler = logging.StreamHandler()
+
         formatter = logging.Formatter("[%(filename)s:%(lineno)s (%(funcName)s)] %(levelname)s: %(message)s")
-        self.handler.setFormatter(formatter)
-        self.log.addHandler(self.handler)
+
+        self.stream_handler = logging.StreamHandler()
+        self.stream_handler.setFormatter(formatter)
+        self.log.addHandler(self.stream_handler)
+
+        self.file_handler = logging.FileHandler(self._error_log_filename)
+        self.file_handler.setFormatter(formatter)
+        self.log.addHandler(self.file_handler)
 
     def detect_supported_drives(self, callback=None):
         """ This method should populate self.drives with supported devices """
@@ -288,7 +294,7 @@ class TailsInstallerCreator(object):
         err = unicode_to_utf8(err)
         self.output.write(out + '\n' + err + '\n')
         if proc.returncode:
-            self.write_log()
+            self.log.info(self.output.getvalue())
             if not passive:
                 raise TailsInstallerError(_(
                         "There was a problem executing the following command: `%(command)s`.\nA more detailed error log has been written to '%(filename)s'.")
@@ -458,11 +464,6 @@ class TailsInstallerCreator(object):
                                          " previous LiveOS: %(message)s")
                                          % {'message': str(e)})
 
-    def write_log(self):
-        """ Write out our subprocess stdout/stderr to a log file """
-        with open(self._error_log_filename, 'a') as out:
-            out.write(self.output.getvalue())
-
     def get_liveos(self):
         return self.get_liveos_file_path(config['main_liveos_dir'])
 
diff --git a/tails_installer/gui.py b/tails_installer/gui.py
index 94b550e..98d0e18 100755
--- a/tails_installer/gui.py
+++ b/tails_installer/gui.py
@@ -340,7 +340,7 @@ class TailsInstallerWindow(Gtk.ApplicationWindow):
         self.handler = TailsInstallerLogHandler(lambda x: self.append_to_log(x))
         self.live.log.addHandler(self.handler)
         if not self.opts.verbose:
-            self.live.log.removeHandler(self.live.handler)
+            self.live.log.removeHandler(self.live.stream_handler)
 
         # If an ISO was specified on the command line, use it.
         if args:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/tails-installer.git



More information about the Pkg-privacy-commits mailing list