瀏覽代碼

Instrument FileScraper read errors rather than use puts

Thibaut Courouble 7 年之前
父節點
當前提交
0095779b3f
共有 2 個文件被更改,包括 5 次插入1 次删除
  1. 1 1
      lib/docs/core/scrapers/file_scraper.rb
  2. 4 0
      lib/docs/subscribers/doc_subscriber.rb

+ 1 - 1
lib/docs/core/scrapers/file_scraper.rb

@@ -41,7 +41,7 @@ module Docs
     def read_file(path)
       File.read(path)
     rescue
-      puts "Failed to open file: #{path}"
+      instrument 'warn.doc', msg: "Failed to open file: #{path}"
       nil
     end
   end

+ 4 - 0
lib/docs/subscribers/doc_subscriber.rb

@@ -26,6 +26,10 @@ module Docs
       log event.payload[:msg]
     end
 
+    def warn(event)
+      log "ERROR: #{event.payload[:msg]}"
+    end
+
     def error(event)
       exception = event.payload[:exception]
       log "ERROR:"