Browse Source

簡化log顯示

ANX 6 years ago
parent
commit
bde91887c4
1 changed files with 31 additions and 3 deletions
  1. 31 3
      lib/ebaytr.rb

+ 31 - 3
lib/ebaytr.rb

@@ -44,8 +44,22 @@ module Ebaytr
 
     req.body = req.body.gsub("'","'")
 
-    puts req.body
-
+    # puts req.body 
+    main_str = ''
+    main_str += " #{hash[:ItemID]}" if hash[:ItemID].present?
+    main_str += " #{hash[:SKU]}" if hash[:SKU].present?
+    if hash[:Item].present?
+      main_str += " #{hash[:Item][:SKU]}" if hash[:Item][:SKU].present?
+    end
+    if main_str.blank?
+      main_str = hash.to_s[0,100]
+    end
+    puts " "
+    puts "========================================"
+    puts "| Trading #{Time.now.to_s(:db)}"
+    puts "| [#{@@site}][#{request_name}]#{main_str}"
+    puts "----------------------------------------"
+    
     res = https.request(req)
     object_hash = Hash.from_xml(res.body)["#{request_name}Response"]
     object_hash
@@ -72,7 +86,21 @@ module Ebaytr
 
     req.body = req.body.gsub("'","'")
 
-    puts req.body
+    # puts req.body
+    main_str = ''
+    main_str += " #{hash[:itemID]}" if hash[:itemID].present?
+    main_str += " #{hash[:SKU]}" if hash[:SKU].present?
+    if hash[:item].present?
+      main_str += " #{hash[:item][:SKU]}" if hash[:item][:SKU].present?
+    end
+    if main_str.blank?
+      main_str = hash.to_s[0,100]
+    end
+    puts " "
+    puts "========================================"
+    puts "| Finding #{Time.now.to_s(:db)}"
+    puts "| [#{@@global_id}][#{request_name}]#{main_str}"
+    puts "----------------------------------------"
 
     res = https.request(req)
     object_hash = Hash.from_xml(res.body)["#{request_name}Response"]