Module: TsJsonApi::Requestor::Logging::ClassMethods

Defined in:
lib/ts_json_api/requestor/logging.rb

Instance Method Summary collapse

Instance Method Details

#log(path, url, str) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ts_json_api/requestor/logging.rb', line 11

def log(path, url, str)
	return unless Configure.logging_enabled?

	if Configure.timestamped_logs?
		path << "_t#{Time.now.to_i}.log"
	else
		path << ".log"
	end

	create_dir_if_not_exists File.dirname(path)
	File.open(Configure::LOG_FILE_DIRECTORY.join(path), 'w') { |f| f.write "[TIME]: #{Time.now}\n[URL]: #{url}\n\n#{str}" }
end