Module: HatenablogPublisher::RequestLogger
Instance Method Summary collapse
Instance Method Details
#log(identifier, text) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/hatenablog_publisher/request_logger.rb', line 11 def log(identifier, text) Dir.mkdir('tmp') unless Dir.exist?('tmp') classname = self.class.to_s.demodulize.downcase filepath = "tmp/hatenablog_publisher-#{classname}-#{identifier}.xml" File.write(filepath, text) p "[Info] #{classname}: #{identifier}. output log -> #{filepath}." end |
#with_logging_request(identifier, request_body, &block) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/hatenablog_publisher/request_logger.rb', line 3 def with_logging_request(identifier, request_body, &block) log("#{identifier}-request", request_body) res = yield log("#{identifier}-response", res.body) res end |