simple_record 1.4.4 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/simple_record.rb +6 -4
- data/lib/simple_record/logging.rb +4 -2
- metadata +3 -3
data/lib/simple_record.rb
CHANGED
@@ -45,7 +45,6 @@ module SimpleRecord
|
|
45
45
|
@@options = {}
|
46
46
|
@@stats = SimpleRecord::Stats.new
|
47
47
|
@@logging = false
|
48
|
-
@@usage_logging_options = {}
|
49
48
|
|
50
49
|
class << self;
|
51
50
|
attr_accessor :aws_access_key, :aws_secret_key
|
@@ -66,19 +65,22 @@ module SimpleRecord
|
|
66
65
|
# Params:
|
67
66
|
# :select=>{:filename=>"file_to_write_to", :format=>"csv"}
|
68
67
|
def log_usage(types={})
|
68
|
+
@usage_logging_options = {} unless @usage_logging_options
|
69
69
|
return if types.nil?
|
70
70
|
types.each_pair do |type, options|
|
71
71
|
options[:lines_between_flushes] = 100 unless options[:lines_between_flushes]
|
72
|
-
|
72
|
+
@usage_logging_options[type] = options
|
73
73
|
end
|
74
|
+
#puts 'SimpleRecord.usage_logging_options=' + SimpleRecord.usage_logging_options.inspect
|
74
75
|
end
|
75
76
|
|
76
77
|
def close_usage_log(type)
|
77
|
-
|
78
|
+
return unless @usage_logging_options[type]
|
79
|
+
@usage_logging_options[type][:file].close if @usage_logging_options[type][:file]
|
78
80
|
end
|
79
81
|
|
80
82
|
def usage_logging_options
|
81
|
-
|
83
|
+
@usage_logging_options
|
82
84
|
end
|
83
85
|
|
84
86
|
def stats
|
@@ -7,7 +7,8 @@ module SimpleRecord
|
|
7
7
|
|
8
8
|
module ClassMethods
|
9
9
|
def write_usage(type, domain, q_type, params, results)
|
10
|
-
#
|
10
|
+
#puts 'params=' + params.inspect
|
11
|
+
#puts 'logging_options=' + SimpleRecord.usage_logging_options.inspect
|
11
12
|
if SimpleRecord.usage_logging_options
|
12
13
|
type_options = SimpleRecord.usage_logging_options[type]
|
13
14
|
if type_options
|
@@ -21,8 +22,9 @@ module SimpleRecord
|
|
21
22
|
line = usage_line(type_options[:format], [type, domain, q_type, conditions, params[:order]], results[:request_id], results[:box_usage])
|
22
23
|
file.puts line
|
23
24
|
type_options[:lines] = type_options[:lines] ? type_options[:lines] + 1 : 1
|
25
|
+
#puts 'lines=' + type_options[:lines].to_s
|
24
26
|
if type_options[:lines] % type_options[:lines_between_flushes] == 0
|
25
|
-
#
|
27
|
+
#puts "flushing to file..."
|
26
28
|
file.flush
|
27
29
|
# sleep 20
|
28
30
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 5
|
10
|
+
version: 1.4.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Travis Reeder
|