[Groonga-commit] ranguba/chupa-text-decomposer-pdf at aa2ca9b [master] Log messages from Poppler

Back to archive index
Kouhei Sutou null+****@clear*****
Mon Mar 4 09:34:46 JST 2019


Kouhei Sutou	2019-03-04 09:34:46 +0900 (Mon, 04 Mar 2019)

  Revision: aa2ca9b67cf5fc7d1200a020fa7c7f865b57b2d1
  https://github.com/ranguba/chupa-text-decomposer-pdf/commit/aa2ca9b67cf5fc7d1200a020fa7c7f865b57b2d1

  Message:
    Log messages from Poppler

  Modified files:
    lib/chupa-text/decomposers/pdf.rb
    test/test-pdf.rb

  Modified: lib/chupa-text/decomposers/pdf.rb (+13 -6)
===================================================================
--- lib/chupa-text/decomposers/pdf.rb    2019-03-04 09:09:27 +0900 (324ce94)
+++ lib/chupa-text/decomposers/pdf.rb    2019-03-04 09:34:46 +0900 (28f663e)
@@ -94,12 +94,19 @@ module ChupaText
 
       def wrap_stderr
         stderr = $stderr.dup
-        input, output = IO.pipe
-        _ = input # TODO: Report output
-        $stderr.reopen(output)
-        yield
-      ensure
-        $stderr.reopen(stderr)
+        stderr_log = Tempfile.new(["chupa-text-decomposer-pdf-stderr", ".log"])
+        begin
+          $stderr.reopen(stderr_log)
+          yield
+        ensure
+          $stderr.reopen(stderr)
+          if stderr_log.size > 0
+            warn do
+              stderr_log.rewind
+              "#{log_tag} Messages from Poppler:\n#{stderr_log.read}"
+            end
+          end
+        end
       end
 
       def add_attribute(text_data, document,

  Modified: test/test-pdf.rb (+4 -0)
===================================================================
--- test/test-pdf.rb    2019-03-04 09:09:27 +0900 (a10f98b)
+++ test/test-pdf.rb    2019-03-04 09:34:46 +0900 (a66171f)
@@ -228,6 +228,10 @@ class TestPDF < Test::Unit::TestCase
         end
         assert_equal([
                        [
+                         :warn,
+                         "[decomposer][pdf] Messages from Poppler:"
+                       ],
+                       [
                          :error,
                          "[decomposer][pdf] Failed to process PDF: " +
                          "Poppler::Error::Damaged: PDF document is damaged",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190304/25e757fa/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index