scribe-logger 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 99b389b7a3ca85ab780fbff0c875d2e5e33f24f1
4
+ data.tar.gz: d6a4b91343538fe7a25c1a98d2aef3924669f7d8
5
+ SHA512:
6
+ metadata.gz: 1c55a1ff4f25b00cbae05c0b73975b09e47a5986229f9babd9f4d51bd4fb296c5df7b8fcbf7b85063b26ab6fa1b40d342d989116d563c83b923266326380e9ad
7
+ data.tar.gz: 55884cfa5b893d9394f9636eac2d76ae4af353b347c4de11c4f841e074aac6caff2f2546c95076e1577422b2510c14b5148bd994eec803716ae5c407a0d494ce
@@ -0,0 +1,5 @@
1
+ .bundle
2
+ Gemfile.lock
3
+ vendor/ruby
4
+ vendor/bundle
5
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in scribe-logger.gemspec
4
+
5
+ gemspec
6
+
7
+
@@ -0,0 +1,47 @@
1
+ ## Description
2
+
3
+ The project MobME Infrastructure Scribe provides scribe logging capabilities to projects, taking in a hive schema as the log template.
4
+
5
+ ## Install
6
+
7
+ Scribe is packaged as a ruby gem, to be easily used. To install, follow the steps below:
8
+
9
+ $ gem install scribe-logger
10
+
11
+ ## Usage
12
+
13
+ $ irb
14
+ > require 'scribe-logger'
15
+ > scribe = Scribe.loggers(:schema_uri => "http://s1.mobme.in/appsuite-vodafone-in/schema.yml")
16
+ > scribe.log_visit(:mobile => "8943011156")
17
+ > scribe.log_event(:event => "sub", :mobile => "8943011156")
18
+
19
+ Scribe.loggers take in the following options as a ruby hash:
20
+ :schema_uri [string]
21
+ :scribe_host [string] = Defaut: localhost
22
+ :scribe_port [integer] = Default: 1464
23
+ :evented [boolean] = Default: false
24
+
25
+ ## Evented Scribe
26
+
27
+ Scribe supports evented scribing [EventMachine Support], to be used in an event driven environment.
28
+
29
+ Points to be noted to enable Evented Scribe
30
+ 1. Set :evented to true in Scribe.logger
31
+ 2. Run your entire application inside a Fiber
32
+ 3. require 'fiber'
33
+
34
+ Example code:
35
+
36
+ require 'scribe-logger'
37
+ require 'fiber'
38
+
39
+ scribe = Scribe.loggers(:schema_uri => "http://s1.mobme.in/appsuite-vodafone-in/schema.yml", :evented => true)
40
+
41
+ EM.run do
42
+ Fiber.new do
43
+ scribe.log_visit(:mobile => "8943011156")
44
+ end.resume
45
+ end
46
+
47
+
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/TODO.md ADDED
@@ -0,0 +1,14 @@
1
+
2
+ # TODO
3
+
4
+
5
+ # CHANGES
6
+
7
+ 20120104 (vishnu@mobme.in)
8
+
9
+ * Silencing irritating warnings around the hive require
10
+ * Eventmachine Thrift is only required if it's an evented environment.
11
+
12
+ Indeterminate (nanda@mobme.in)
13
+
14
+ * Lots of work!
@@ -0,0 +1,29 @@
1
+ $: << File.expand_path("../../vendor/scribe-thrift/gen-rb", __FILE__)
2
+ $current_path = File.dirname(File.expand_path(__FILE__))
3
+ require "#{$current_path}/scribe_logger/version"
4
+
5
+ module Scribe
6
+ require 'active_support'
7
+ require 'active_support/core_ext/kernel'
8
+ require 'active_record'
9
+
10
+ silence_warnings do
11
+ require 'activerecord-hive-adapter'
12
+ end
13
+
14
+ require 'active_record/connection_adapters/hive_adapter'
15
+ require 'thrift_client'
16
+ require 'thrift_client/event_machine' if defined? EventMachine
17
+ begin
18
+ require 'active_support/time'
19
+ require 'active_support/core_ext/hash'
20
+ rescue LoadError
21
+ require 'active_support'
22
+ end
23
+ require 'open-uri'
24
+ require 'uuid'
25
+
26
+ require "#{File.expand_path("../../vendor/scribe-thrift/gen-rb", __FILE__)}/scribe"
27
+ require "#{$current_path}/scribe_logger/scribe_connection"
28
+ require "#{$current_path}/scribe_logger/scribe"
29
+ end
@@ -0,0 +1,115 @@
1
+ module Scribe
2
+ class << self
3
+
4
+ @@default_config = {
5
+ :scribe_host => '127.0.0.1',
6
+ :scribe_port => 1464,
7
+ :noscribe => false, # Set this to true if you dont want to log to scribe-logger.
8
+ :tzone => 'Kolkata',
9
+ :evented => false,
10
+ }
11
+
12
+ def loggers(config)
13
+ config = merge_defaults(config)
14
+ scribe_connection = connected_scribe(config)
15
+ database = YAML.load(open(config[:schema_uri]).read)
16
+ hostname = IO.popen('hostname').read.strip
17
+ loggers = database['tables'].map do |table_name, table_def|
18
+ columns = []
19
+ table_def['columns'].each do |col_name, col_def|
20
+ args = [col_name] + col_def.values_at('default', 'type', 'partition')
21
+ columns << ActiveRecord::ConnectionAdapters::HiveColumn.new(*args)
22
+ end
23
+ options = {
24
+ :database => config[:database] || database['name'],
25
+ :table => table_name,
26
+ :columns => columns,
27
+ :noscribe => config[:noscribe],
28
+ :tzone => config[:tzone],
29
+ :writes_to_legacy_scribe => database['writes_to_legacy_scribe'] || false,
30
+ :hostname => hostname,
31
+ }
32
+ logger_name = "log_#{table_name.singularize.underscore}"
33
+ logger_proc = make_logger_proc(scribe_connection, options)
34
+ [logger_name, logger_proc]
35
+ end
36
+ Module.new {
37
+ loggers.each do |name, proc|
38
+ define_method(name, proc)
39
+ module_function(name)
40
+ end
41
+ }
42
+ end
43
+
44
+ private
45
+ def merge_defaults(config)
46
+ @@default_config.merge(config.symbolize_keys)
47
+ end
48
+
49
+ def connected_scribe(config)
50
+ scribe_connection = ScribeConnection.new("#{config[:scribe_host]}:#{config[:scribe_port]}", config[:evented])
51
+ if defined?(PhusionPassenger)
52
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
53
+ if forked
54
+ scribe_connection.reconnect!
55
+ end
56
+ end
57
+ end
58
+ scribe_connection
59
+ end
60
+
61
+ def make_logger_proc(scribe_connection, options)
62
+ database = options[:database]
63
+ table = options[:table]
64
+ partitions = options[:columns].select { |c| c.partition? }
65
+ columns = options[:columns].reject { |c| c.partition? }
66
+ Proc.new do |*args|
67
+ obj, hash = args
68
+ params =
69
+ if obj.respond_to?(:to_scribe)
70
+ obj.to_scribe.merge(hash || {})
71
+ elsif obj.kind_of?(Hash)
72
+ obj
73
+ else
74
+ hash || {}
75
+ end
76
+ logstr = columns.map do |c|
77
+ val = params[c.name.to_sym] || c.realized_default
78
+ val = if (val.kind_of?(DateTime) || val.kind_of?(Time))
79
+ val.in_time_zone(options[:tzone]).strftime("%Y-%m-%d %H:%M:%S")
80
+ elsif val.kind_of?(Date)
81
+ val.to_datetime.in_time_zone(options[:tzone]).strftime("%Y-%m-%d")
82
+ elsif c.name.to_sym == :uuid
83
+ UUID.generate
84
+ elsif c.name.to_sym == :client_hostname
85
+ options[:hostname]
86
+ else
87
+ val
88
+ end
89
+ end.join("\t")
90
+ logstr << "\n"
91
+ partition_spec = partitions.map do |p|
92
+ val = params[p.name.to_sym] || p.realized_default || "nil"
93
+ val = if val.kind_of?(Date)
94
+ # convert date to string in given timezone relative to current time.
95
+ full_datestr = val.strftime("%Y-%m-%d") + DateTime.now.strftime(" %H:%M:%S")
96
+ DateTime.
97
+ strptime(full_datestr, "%Y-%m-%d %H:%M:%S").
98
+ in_time_zone(options[:tzone]).
99
+ strftime("%Y-%m-%d")
100
+ else
101
+ val
102
+ end
103
+ "#{p.name}=#{val}"
104
+ end.join("/")
105
+ category = options[:writes_to_legacy_scribe] ? table : "#{database}.db/#{table}/#{partition_spec}"
106
+ if true == options[:noscribe]
107
+ puts "[scribe] #{category}: #{logstr}"
108
+ else
109
+ scribe_connection.log(category, logstr)
110
+ end
111
+ end
112
+ end
113
+
114
+ end
115
+ end
@@ -0,0 +1,18 @@
1
+ module Scribe
2
+ class ScribeConnection
3
+ def initialize(server, evented)
4
+ options = { :protocol_extra_params => false }
5
+ options.update({ :transport => Thrift::EventMachineTransport }) if evented == true
6
+ @client = ::ThriftClient.new(ScribeThrift::Client, [server], options)
7
+ end
8
+
9
+ def log(category, message)
10
+ entry = ScribeThrift::LogEntry.new(:message => message, :category => category)
11
+ @client.Log([entry])
12
+ end
13
+
14
+ def reconnect!
15
+ @client.connect!
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Scribe
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'scribe_logger/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'scribe-logger'
7
+ s.version = Scribe::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Nanda Sankaran']
10
+ s.email = ['nanda@mobme.in']
11
+ s.homepage = ''
12
+ s.summary = %q{A scribe logger for writing to Hive tables}
13
+ s.description = %q{A scribe logger for writing to Hive tables}
14
+
15
+ s.rubyforge_project = 'scribe-logger'
16
+
17
+ s.add_dependency('rack')
18
+ s.add_dependency('activerecord')
19
+ s.add_dependency('thrift_client')
20
+ s.add_dependency('uuid')
21
+ s.add_dependency('activerecord-hive-adapter')
22
+
23
+ s.add_development_dependency('rake')
24
+
25
+ s.files = `git ls-files`.split("\n")
26
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
28
+ s.require_paths = ['lib']
29
+ end
@@ -0,0 +1,700 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'fb303_types'
9
+
10
+ module FacebookService
11
+ class Client
12
+ include ::Thrift::Client
13
+
14
+ def getName()
15
+ send_getName()
16
+ return recv_getName()
17
+ end
18
+
19
+ def send_getName()
20
+ send_message('getName', GetName_args)
21
+ end
22
+
23
+ def recv_getName()
24
+ result = receive_message(GetName_result)
25
+ return result.success unless result.success.nil?
26
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getName failed: unknown result')
27
+ end
28
+
29
+ def getVersion()
30
+ send_getVersion()
31
+ return recv_getVersion()
32
+ end
33
+
34
+ def send_getVersion()
35
+ send_message('getVersion', GetVersion_args)
36
+ end
37
+
38
+ def recv_getVersion()
39
+ result = receive_message(GetVersion_result)
40
+ return result.success unless result.success.nil?
41
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getVersion failed: unknown result')
42
+ end
43
+
44
+ def getStatus()
45
+ send_getStatus()
46
+ return recv_getStatus()
47
+ end
48
+
49
+ def send_getStatus()
50
+ send_message('getStatus', GetStatus_args)
51
+ end
52
+
53
+ def recv_getStatus()
54
+ result = receive_message(GetStatus_result)
55
+ return result.success unless result.success.nil?
56
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getStatus failed: unknown result')
57
+ end
58
+
59
+ def getStatusDetails()
60
+ send_getStatusDetails()
61
+ return recv_getStatusDetails()
62
+ end
63
+
64
+ def send_getStatusDetails()
65
+ send_message('getStatusDetails', GetStatusDetails_args)
66
+ end
67
+
68
+ def recv_getStatusDetails()
69
+ result = receive_message(GetStatusDetails_result)
70
+ return result.success unless result.success.nil?
71
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getStatusDetails failed: unknown result')
72
+ end
73
+
74
+ def getCounters()
75
+ send_getCounters()
76
+ return recv_getCounters()
77
+ end
78
+
79
+ def send_getCounters()
80
+ send_message('getCounters', GetCounters_args)
81
+ end
82
+
83
+ def recv_getCounters()
84
+ result = receive_message(GetCounters_result)
85
+ return result.success unless result.success.nil?
86
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getCounters failed: unknown result')
87
+ end
88
+
89
+ def getCounter(key)
90
+ send_getCounter(key)
91
+ return recv_getCounter()
92
+ end
93
+
94
+ def send_getCounter(key)
95
+ send_message('getCounter', GetCounter_args, :key => key)
96
+ end
97
+
98
+ def recv_getCounter()
99
+ result = receive_message(GetCounter_result)
100
+ return result.success unless result.success.nil?
101
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getCounter failed: unknown result')
102
+ end
103
+
104
+ def setOption(key, value)
105
+ send_setOption(key, value)
106
+ recv_setOption()
107
+ end
108
+
109
+ def send_setOption(key, value)
110
+ send_message('setOption', SetOption_args, :key => key, :value => value)
111
+ end
112
+
113
+ def recv_setOption()
114
+ result = receive_message(SetOption_result)
115
+ return
116
+ end
117
+
118
+ def getOption(key)
119
+ send_getOption(key)
120
+ return recv_getOption()
121
+ end
122
+
123
+ def send_getOption(key)
124
+ send_message('getOption', GetOption_args, :key => key)
125
+ end
126
+
127
+ def recv_getOption()
128
+ result = receive_message(GetOption_result)
129
+ return result.success unless result.success.nil?
130
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getOption failed: unknown result')
131
+ end
132
+
133
+ def getOptions()
134
+ send_getOptions()
135
+ return recv_getOptions()
136
+ end
137
+
138
+ def send_getOptions()
139
+ send_message('getOptions', GetOptions_args)
140
+ end
141
+
142
+ def recv_getOptions()
143
+ result = receive_message(GetOptions_result)
144
+ return result.success unless result.success.nil?
145
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getOptions failed: unknown result')
146
+ end
147
+
148
+ def getCpuProfile(profileDurationInSec)
149
+ send_getCpuProfile(profileDurationInSec)
150
+ return recv_getCpuProfile()
151
+ end
152
+
153
+ def send_getCpuProfile(profileDurationInSec)
154
+ send_message('getCpuProfile', GetCpuProfile_args, :profileDurationInSec => profileDurationInSec)
155
+ end
156
+
157
+ def recv_getCpuProfile()
158
+ result = receive_message(GetCpuProfile_result)
159
+ return result.success unless result.success.nil?
160
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getCpuProfile failed: unknown result')
161
+ end
162
+
163
+ def aliveSince()
164
+ send_aliveSince()
165
+ return recv_aliveSince()
166
+ end
167
+
168
+ def send_aliveSince()
169
+ send_message('aliveSince', AliveSince_args)
170
+ end
171
+
172
+ def recv_aliveSince()
173
+ result = receive_message(AliveSince_result)
174
+ return result.success unless result.success.nil?
175
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'aliveSince failed: unknown result')
176
+ end
177
+
178
+ def reinitialize()
179
+ send_reinitialize()
180
+ end
181
+
182
+ def send_reinitialize()
183
+ send_message('reinitialize', Reinitialize_args)
184
+ end
185
+ def shutdown()
186
+ send_shutdown()
187
+ end
188
+
189
+ def send_shutdown()
190
+ send_message('shutdown', Shutdown_args)
191
+ end
192
+ end
193
+
194
+ class Processor
195
+ include ::Thrift::Processor
196
+
197
+ def process_getName(seqid, iprot, oprot)
198
+ args = read_args(iprot, GetName_args)
199
+ result = GetName_result.new()
200
+ result.success = @handler.getName()
201
+ write_result(result, oprot, 'getName', seqid)
202
+ end
203
+
204
+ def process_getVersion(seqid, iprot, oprot)
205
+ args = read_args(iprot, GetVersion_args)
206
+ result = GetVersion_result.new()
207
+ result.success = @handler.getVersion()
208
+ write_result(result, oprot, 'getVersion', seqid)
209
+ end
210
+
211
+ def process_getStatus(seqid, iprot, oprot)
212
+ args = read_args(iprot, GetStatus_args)
213
+ result = GetStatus_result.new()
214
+ result.success = @handler.getStatus()
215
+ write_result(result, oprot, 'getStatus', seqid)
216
+ end
217
+
218
+ def process_getStatusDetails(seqid, iprot, oprot)
219
+ args = read_args(iprot, GetStatusDetails_args)
220
+ result = GetStatusDetails_result.new()
221
+ result.success = @handler.getStatusDetails()
222
+ write_result(result, oprot, 'getStatusDetails', seqid)
223
+ end
224
+
225
+ def process_getCounters(seqid, iprot, oprot)
226
+ args = read_args(iprot, GetCounters_args)
227
+ result = GetCounters_result.new()
228
+ result.success = @handler.getCounters()
229
+ write_result(result, oprot, 'getCounters', seqid)
230
+ end
231
+
232
+ def process_getCounter(seqid, iprot, oprot)
233
+ args = read_args(iprot, GetCounter_args)
234
+ result = GetCounter_result.new()
235
+ result.success = @handler.getCounter(args.key)
236
+ write_result(result, oprot, 'getCounter', seqid)
237
+ end
238
+
239
+ def process_setOption(seqid, iprot, oprot)
240
+ args = read_args(iprot, SetOption_args)
241
+ result = SetOption_result.new()
242
+ @handler.setOption(args.key, args.value)
243
+ write_result(result, oprot, 'setOption', seqid)
244
+ end
245
+
246
+ def process_getOption(seqid, iprot, oprot)
247
+ args = read_args(iprot, GetOption_args)
248
+ result = GetOption_result.new()
249
+ result.success = @handler.getOption(args.key)
250
+ write_result(result, oprot, 'getOption', seqid)
251
+ end
252
+
253
+ def process_getOptions(seqid, iprot, oprot)
254
+ args = read_args(iprot, GetOptions_args)
255
+ result = GetOptions_result.new()
256
+ result.success = @handler.getOptions()
257
+ write_result(result, oprot, 'getOptions', seqid)
258
+ end
259
+
260
+ def process_getCpuProfile(seqid, iprot, oprot)
261
+ args = read_args(iprot, GetCpuProfile_args)
262
+ result = GetCpuProfile_result.new()
263
+ result.success = @handler.getCpuProfile(args.profileDurationInSec)
264
+ write_result(result, oprot, 'getCpuProfile', seqid)
265
+ end
266
+
267
+ def process_aliveSince(seqid, iprot, oprot)
268
+ args = read_args(iprot, AliveSince_args)
269
+ result = AliveSince_result.new()
270
+ result.success = @handler.aliveSince()
271
+ write_result(result, oprot, 'aliveSince', seqid)
272
+ end
273
+
274
+ def process_reinitialize(seqid, iprot, oprot)
275
+ args = read_args(iprot, Reinitialize_args)
276
+ @handler.reinitialize()
277
+ return
278
+ end
279
+
280
+ def process_shutdown(seqid, iprot, oprot)
281
+ args = read_args(iprot, Shutdown_args)
282
+ @handler.shutdown()
283
+ return
284
+ end
285
+
286
+ end
287
+
288
+ # HELPER FUNCTIONS AND STRUCTURES
289
+
290
+ class GetName_args
291
+ include ::Thrift::Struct, ::Thrift::Struct_Union
292
+
293
+ FIELDS = {
294
+
295
+ }
296
+
297
+ def struct_fields; FIELDS; end
298
+
299
+ def validate
300
+ end
301
+
302
+ ::Thrift::Struct.generate_accessors self
303
+ end
304
+
305
+ class GetName_result
306
+ include ::Thrift::Struct, ::Thrift::Struct_Union
307
+ SUCCESS = 0
308
+
309
+ FIELDS = {
310
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
311
+ }
312
+
313
+ def struct_fields; FIELDS; end
314
+
315
+ def validate
316
+ end
317
+
318
+ ::Thrift::Struct.generate_accessors self
319
+ end
320
+
321
+ class GetVersion_args
322
+ include ::Thrift::Struct, ::Thrift::Struct_Union
323
+
324
+ FIELDS = {
325
+
326
+ }
327
+
328
+ def struct_fields; FIELDS; end
329
+
330
+ def validate
331
+ end
332
+
333
+ ::Thrift::Struct.generate_accessors self
334
+ end
335
+
336
+ class GetVersion_result
337
+ include ::Thrift::Struct, ::Thrift::Struct_Union
338
+ SUCCESS = 0
339
+
340
+ FIELDS = {
341
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
342
+ }
343
+
344
+ def struct_fields; FIELDS; end
345
+
346
+ def validate
347
+ end
348
+
349
+ ::Thrift::Struct.generate_accessors self
350
+ end
351
+
352
+ class GetStatus_args
353
+ include ::Thrift::Struct, ::Thrift::Struct_Union
354
+
355
+ FIELDS = {
356
+
357
+ }
358
+
359
+ def struct_fields; FIELDS; end
360
+
361
+ def validate
362
+ end
363
+
364
+ ::Thrift::Struct.generate_accessors self
365
+ end
366
+
367
+ class GetStatus_result
368
+ include ::Thrift::Struct, ::Thrift::Struct_Union
369
+ SUCCESS = 0
370
+
371
+ FIELDS = {
372
+ SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success', :enum_class => Fb_status}
373
+ }
374
+
375
+ def struct_fields; FIELDS; end
376
+
377
+ def validate
378
+ unless @success.nil? || Fb_status::VALID_VALUES.include?(@success)
379
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!')
380
+ end
381
+ end
382
+
383
+ ::Thrift::Struct.generate_accessors self
384
+ end
385
+
386
+ class GetStatusDetails_args
387
+ include ::Thrift::Struct, ::Thrift::Struct_Union
388
+
389
+ FIELDS = {
390
+
391
+ }
392
+
393
+ def struct_fields; FIELDS; end
394
+
395
+ def validate
396
+ end
397
+
398
+ ::Thrift::Struct.generate_accessors self
399
+ end
400
+
401
+ class GetStatusDetails_result
402
+ include ::Thrift::Struct, ::Thrift::Struct_Union
403
+ SUCCESS = 0
404
+
405
+ FIELDS = {
406
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
407
+ }
408
+
409
+ def struct_fields; FIELDS; end
410
+
411
+ def validate
412
+ end
413
+
414
+ ::Thrift::Struct.generate_accessors self
415
+ end
416
+
417
+ class GetCounters_args
418
+ include ::Thrift::Struct, ::Thrift::Struct_Union
419
+
420
+ FIELDS = {
421
+
422
+ }
423
+
424
+ def struct_fields; FIELDS; end
425
+
426
+ def validate
427
+ end
428
+
429
+ ::Thrift::Struct.generate_accessors self
430
+ end
431
+
432
+ class GetCounters_result
433
+ include ::Thrift::Struct, ::Thrift::Struct_Union
434
+ SUCCESS = 0
435
+
436
+ FIELDS = {
437
+ SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::I64}}
438
+ }
439
+
440
+ def struct_fields; FIELDS; end
441
+
442
+ def validate
443
+ end
444
+
445
+ ::Thrift::Struct.generate_accessors self
446
+ end
447
+
448
+ class GetCounter_args
449
+ include ::Thrift::Struct, ::Thrift::Struct_Union
450
+ KEY = 1
451
+
452
+ FIELDS = {
453
+ KEY => {:type => ::Thrift::Types::STRING, :name => 'key'}
454
+ }
455
+
456
+ def struct_fields; FIELDS; end
457
+
458
+ def validate
459
+ end
460
+
461
+ ::Thrift::Struct.generate_accessors self
462
+ end
463
+
464
+ class GetCounter_result
465
+ include ::Thrift::Struct, ::Thrift::Struct_Union
466
+ SUCCESS = 0
467
+
468
+ FIELDS = {
469
+ SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'}
470
+ }
471
+
472
+ def struct_fields; FIELDS; end
473
+
474
+ def validate
475
+ end
476
+
477
+ ::Thrift::Struct.generate_accessors self
478
+ end
479
+
480
+ class SetOption_args
481
+ include ::Thrift::Struct, ::Thrift::Struct_Union
482
+ KEY = 1
483
+ VALUE = 2
484
+
485
+ FIELDS = {
486
+ KEY => {:type => ::Thrift::Types::STRING, :name => 'key'},
487
+ VALUE => {:type => ::Thrift::Types::STRING, :name => 'value'}
488
+ }
489
+
490
+ def struct_fields; FIELDS; end
491
+
492
+ def validate
493
+ end
494
+
495
+ ::Thrift::Struct.generate_accessors self
496
+ end
497
+
498
+ class SetOption_result
499
+ include ::Thrift::Struct, ::Thrift::Struct_Union
500
+
501
+ FIELDS = {
502
+
503
+ }
504
+
505
+ def struct_fields; FIELDS; end
506
+
507
+ def validate
508
+ end
509
+
510
+ ::Thrift::Struct.generate_accessors self
511
+ end
512
+
513
+ class GetOption_args
514
+ include ::Thrift::Struct, ::Thrift::Struct_Union
515
+ KEY = 1
516
+
517
+ FIELDS = {
518
+ KEY => {:type => ::Thrift::Types::STRING, :name => 'key'}
519
+ }
520
+
521
+ def struct_fields; FIELDS; end
522
+
523
+ def validate
524
+ end
525
+
526
+ ::Thrift::Struct.generate_accessors self
527
+ end
528
+
529
+ class GetOption_result
530
+ include ::Thrift::Struct, ::Thrift::Struct_Union
531
+ SUCCESS = 0
532
+
533
+ FIELDS = {
534
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
535
+ }
536
+
537
+ def struct_fields; FIELDS; end
538
+
539
+ def validate
540
+ end
541
+
542
+ ::Thrift::Struct.generate_accessors self
543
+ end
544
+
545
+ class GetOptions_args
546
+ include ::Thrift::Struct, ::Thrift::Struct_Union
547
+
548
+ FIELDS = {
549
+
550
+ }
551
+
552
+ def struct_fields; FIELDS; end
553
+
554
+ def validate
555
+ end
556
+
557
+ ::Thrift::Struct.generate_accessors self
558
+ end
559
+
560
+ class GetOptions_result
561
+ include ::Thrift::Struct, ::Thrift::Struct_Union
562
+ SUCCESS = 0
563
+
564
+ FIELDS = {
565
+ SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
566
+ }
567
+
568
+ def struct_fields; FIELDS; end
569
+
570
+ def validate
571
+ end
572
+
573
+ ::Thrift::Struct.generate_accessors self
574
+ end
575
+
576
+ class GetCpuProfile_args
577
+ include ::Thrift::Struct, ::Thrift::Struct_Union
578
+ PROFILEDURATIONINSEC = 1
579
+
580
+ FIELDS = {
581
+ PROFILEDURATIONINSEC => {:type => ::Thrift::Types::I32, :name => 'profileDurationInSec'}
582
+ }
583
+
584
+ def struct_fields; FIELDS; end
585
+
586
+ def validate
587
+ end
588
+
589
+ ::Thrift::Struct.generate_accessors self
590
+ end
591
+
592
+ class GetCpuProfile_result
593
+ include ::Thrift::Struct, ::Thrift::Struct_Union
594
+ SUCCESS = 0
595
+
596
+ FIELDS = {
597
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
598
+ }
599
+
600
+ def struct_fields; FIELDS; end
601
+
602
+ def validate
603
+ end
604
+
605
+ ::Thrift::Struct.generate_accessors self
606
+ end
607
+
608
+ class AliveSince_args
609
+ include ::Thrift::Struct, ::Thrift::Struct_Union
610
+
611
+ FIELDS = {
612
+
613
+ }
614
+
615
+ def struct_fields; FIELDS; end
616
+
617
+ def validate
618
+ end
619
+
620
+ ::Thrift::Struct.generate_accessors self
621
+ end
622
+
623
+ class AliveSince_result
624
+ include ::Thrift::Struct, ::Thrift::Struct_Union
625
+ SUCCESS = 0
626
+
627
+ FIELDS = {
628
+ SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'}
629
+ }
630
+
631
+ def struct_fields; FIELDS; end
632
+
633
+ def validate
634
+ end
635
+
636
+ ::Thrift::Struct.generate_accessors self
637
+ end
638
+
639
+ class Reinitialize_args
640
+ include ::Thrift::Struct, ::Thrift::Struct_Union
641
+
642
+ FIELDS = {
643
+
644
+ }
645
+
646
+ def struct_fields; FIELDS; end
647
+
648
+ def validate
649
+ end
650
+
651
+ ::Thrift::Struct.generate_accessors self
652
+ end
653
+
654
+ class Reinitialize_result
655
+ include ::Thrift::Struct, ::Thrift::Struct_Union
656
+
657
+ FIELDS = {
658
+
659
+ }
660
+
661
+ def struct_fields; FIELDS; end
662
+
663
+ def validate
664
+ end
665
+
666
+ ::Thrift::Struct.generate_accessors self
667
+ end
668
+
669
+ class Shutdown_args
670
+ include ::Thrift::Struct, ::Thrift::Struct_Union
671
+
672
+ FIELDS = {
673
+
674
+ }
675
+
676
+ def struct_fields; FIELDS; end
677
+
678
+ def validate
679
+ end
680
+
681
+ ::Thrift::Struct.generate_accessors self
682
+ end
683
+
684
+ class Shutdown_result
685
+ include ::Thrift::Struct, ::Thrift::Struct_Union
686
+
687
+ FIELDS = {
688
+
689
+ }
690
+
691
+ def struct_fields; FIELDS; end
692
+
693
+ def validate
694
+ end
695
+
696
+ ::Thrift::Struct.generate_accessors self
697
+ end
698
+
699
+ end
700
+
@@ -0,0 +1,8 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'fb303_types'
8
+
@@ -0,0 +1,18 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+
8
+ module Fb_status
9
+ DEAD = 0
10
+ STARTING = 1
11
+ ALIVE = 2
12
+ STOPPING = 3
13
+ STOPPED = 4
14
+ WARNING = 5
15
+ VALUE_MAP = {0 => "DEAD", 1 => "STARTING", 2 => "ALIVE", 3 => "STOPPING", 4 => "STOPPED", 5 => "WARNING"}
16
+ VALID_VALUES = Set.new([DEAD, STARTING, ALIVE, STOPPING, STOPPED, WARNING]).freeze
17
+ end
18
+
@@ -0,0 +1,82 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'facebook_service'
9
+ require 'scribe_types'
10
+
11
+ module ScribeThrift
12
+ class Client < FacebookService::Client
13
+ include ::Thrift::Client
14
+
15
+ def Log(messages)
16
+ send_Log(messages)
17
+ return recv_Log()
18
+ end
19
+
20
+ def send_Log(messages)
21
+ send_message('Log', Log_args, :messages => messages)
22
+ end
23
+
24
+ def recv_Log()
25
+ result = receive_message(Log_result)
26
+ return result.success unless result.success.nil?
27
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'Log failed: unknown result')
28
+ end
29
+
30
+ end
31
+
32
+ class Processor < FacebookService::Processor
33
+ include ::Thrift::Processor
34
+
35
+ def process_Log(seqid, iprot, oprot)
36
+ args = read_args(iprot, Log_args)
37
+ result = Log_result.new()
38
+ result.success = @handler.Log(args.messages)
39
+ write_result(result, oprot, 'Log', seqid)
40
+ end
41
+
42
+ end
43
+
44
+ # HELPER FUNCTIONS AND STRUCTURES
45
+
46
+ class Log_args
47
+ include ::Thrift::Struct, ::Thrift::Struct_Union
48
+ MESSAGES = 1
49
+
50
+ FIELDS = {
51
+ MESSAGES => {:type => ::Thrift::Types::LIST, :name => 'messages', :element => {:type => ::Thrift::Types::STRUCT, :class => LogEntry}}
52
+ }
53
+
54
+ def struct_fields; FIELDS; end
55
+
56
+ def validate
57
+ end
58
+
59
+ ::Thrift::Struct.generate_accessors self
60
+ end
61
+
62
+ class Log_result
63
+ include ::Thrift::Struct, ::Thrift::Struct_Union
64
+ SUCCESS = 0
65
+
66
+ FIELDS = {
67
+ SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success', :enum_class => ResultCode}
68
+ }
69
+
70
+ def struct_fields; FIELDS; end
71
+
72
+ def validate
73
+ unless @success.nil? || ResultCode::VALID_VALUES.include?(@success)
74
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!')
75
+ end
76
+ end
77
+
78
+ ::Thrift::Struct.generate_accessors self
79
+ end
80
+
81
+ end
82
+
@@ -0,0 +1,8 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'scribe_types'
8
+
@@ -0,0 +1,36 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'fb303_types'
8
+
9
+ module ScribeThrift
10
+
11
+ module ResultCode
12
+ OK = 0
13
+ TRY_LATER = 1
14
+ VALUE_MAP = {0 => "OK", 1 => "TRY_LATER"}
15
+ VALID_VALUES = Set.new([OK, TRY_LATER]).freeze
16
+ end
17
+
18
+ class LogEntry
19
+ include ::Thrift::Struct, ::Thrift::Struct_Union
20
+ CATEGORY = 1
21
+ MESSAGE = 2
22
+
23
+ FIELDS = {
24
+ CATEGORY => {:type => ::Thrift::Types::STRING, :name => 'category'},
25
+ MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
26
+ }
27
+
28
+ def struct_fields; FIELDS; end
29
+
30
+ def validate
31
+ end
32
+
33
+ ::Thrift::Struct.generate_accessors self
34
+ end
35
+
36
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scribe-logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nanda Sankaran
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thrift_client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: uuid
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activerecord-hive-adapter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A scribe logger for writing to Hive tables
98
+ email:
99
+ - nanda@mobme.in
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - README.md
107
+ - Rakefile
108
+ - TODO.md
109
+ - lib/scribe-logger.rb
110
+ - lib/scribe_logger/scribe.rb
111
+ - lib/scribe_logger/scribe_connection.rb
112
+ - lib/scribe_logger/version.rb
113
+ - pkg/scribe-0.0.1.gem
114
+ - scribe-logger.gemspec
115
+ - vendor/scribe-thrift/gen-rb/facebook_service.rb
116
+ - vendor/scribe-thrift/gen-rb/fb303_constants.rb
117
+ - vendor/scribe-thrift/gen-rb/fb303_types.rb
118
+ - vendor/scribe-thrift/gen-rb/scribe.rb
119
+ - vendor/scribe-thrift/gen-rb/scribe_constants.rb
120
+ - vendor/scribe-thrift/gen-rb/scribe_types.rb
121
+ homepage: ''
122
+ licenses: []
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project: scribe-logger
140
+ rubygems_version: 2.2.2
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: A scribe logger for writing to Hive tables
144
+ test_files: []
145
+ has_rdoc: