I made taks file at lib/tasks
and task file always logging file at out project log directory
and I know where occured error line
now logging line custom text "line N occured"
below is my tasks.rb file
17 log_file = File.open("#{Rails.root}/log/log_file.log", "w")
18
19 begin
20 number_of_row = 8000
21 process_page = args[:page].to_i
22
23 conn_url = CONNECTION_URL
24 xml_page = Nokogiri::XML(open(conn_url))
25
26 root = xml_page.css("root")
27 if root.css("code").text != "0000"
28
29
30
31 log_file.write "\n\n-------------------------------"
32 log_file.write "Line 32 ---------------------------\n\n"
33 log_file.write "Parse Error : #{conn_url},\n code : #{root.css("code").text}, \n msg: #{root.css("message").text} "
34 log_file.write "\n\n-------------------------------\n\n"
35 end
36 rescue => e
37 log_file.write "Line 37 ---------------------------\n\n"
38 log_file.write "Line 37 ---------------------------\n\n"
39 end
How to get line number and log these info?