Commit 09cae40e by lra

sms日志添加

parent 8a3c1a4b
......@@ -151,6 +151,17 @@ class SmsSender
@source.dingtalk_call_set_user_list(opts)
end
# Example:
# SmsSender.info('xxxx')
def self.info(msg)
if defined? ::Rails
@logger ||= ActiveSupport::Logger.new("#{Rails.root}/log/sms_sender.log", "weekly")
@logger.info "#{msg}"
else
puts msg
end
end
protected
def backend(translations)
......
......@@ -99,12 +99,12 @@ module Sms
def post
res = Net::HTTP.post_form(URI.parse('https://eco.taobao.com/router/rest'), extend_params)
puts "#{request_params[:method]} request params: #{request_params.inspect}"
SmsSender.info "#{request_params[:method]} request params: #{request_params.inspect}"
data = res.body
data = JSON.parse(data) if data.is_a? String
puts "#{request_params[:method]} request result: #{data.inspect}"
SmsSender.info "#{request_params[:method]} request result: #{data.inspect}"
result = HashWithIndifferentAccess.new data
keys = result.keys
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment