lib/include/class_log.rb in knjappserver-0.0.15 vs lib/include/class_log.rb in knjappserver-0.0.16
- old
+ new
@@ -32,25 +32,53 @@
return d.ob.list_bysql(:Log, sql)
end
def self.add(d)
- if !d.data.has_key?(:date_saved)
- d.data[:date_saved] = d.db.date_out(Knj::Datet.new)
- end
+ d.data[:date_saved] = Time.now if !d.data.key?(:date_saved)
end
def text
return ob.get(:Log_data_value, self[:text_value_id])[:value]
end
+ def comment
+ return "" if self[:comment_data_id].to_i == 0
+ log_data = ob.get(:Log_data_value, self[:comment_data_id])
+ return "" if !log_data
+ return log_data[:value]
+ end
+
+ def tag
+ return "" if self[:tag_data_id].to_i == 0
+ log_data = ob.get(:Log_data_value, self[:tag_data_id])
+ return "" if !log_data
+ return log_data[:value]
+ end
+
def get
ob.args[:knjappserver].log_data_hash(self[:get_keys_data_id], self[:get_values_data_id])
end
def post
ob.args[:knjappserver].log_data_hash(self[:post_keys_data_id], self[:post_values_data_id])
end
+
+ def cookie
+ ob.args[:knjappserver].log_data_hash(self[:cookie_keys_data_id], self[:cookie_values_data_id])
+ end
+
+ def meta
+ ob.args[:knjappserver].log_data_hash(self[:meta_keys_data_id], self[:meta_values_data_id])
+ end
+
+ def ip
+ meta_d = self.meta
+
+ return meta_d[:HTTP_X_FORWARDED_FOR] if meta_d.has_key?(:HTTP_X_FORWARDED_FOR)
+ return meta_d[:REMOTE_ADDR] if meta_d.has_key?(:REMOTE_ADDR)
+ return "[no ip logged]"
+ end
def first_line
lines = self.text.to_s.split("\n").first.to_s
end
\ No newline at end of file