logdna 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fce964a7d0d13ab47244215c74e7add724677be
4
- data.tar.gz: 490c66b698f2b920213401a8c39b27739d6b63f2
3
+ metadata.gz: f4e7d9d38989aa4c8ec3103f0cab3e25542e014f
4
+ data.tar.gz: bf903b372df4d3efc13a369bb1b6249ce64ad615
5
5
  SHA512:
6
- metadata.gz: 8eaa835e5607907d646b3a1d8cb1e74f9badad6bf54c18fa6dd8411abe874a207af73a32c4b65ccaea4cec43120c61746005a8b0cfb54201c8a927fde5c3bab4
7
- data.tar.gz: 02fa93c986925a06976728cd042ed5a370a9727e2d2151b8158981844b69982a4a12f724405b802e1d50b4b5f1556d31cf1a78bd6516679d784d7eec734388e4
6
+ metadata.gz: 2026c77d627b4f209790a959a3e3d326b2080fec8b88fb678151b889b4bb5424179a3fe2ecb34ab9d6c184047d29f24b5a69a2a2b17736b4b3dab8b70c1a0366
7
+ data.tar.gz: 4689947e4595e22109867df5235d11371190086d5cec3147fe9d23f6307e87b19a69815c1ee5a6d3beb9a338b59411c39af78ef0c238e428015dc18394c5d760
@@ -0,0 +1 @@
1
+ 2.2.0
@@ -7,7 +7,7 @@ module Logdna
7
7
  class Ruby
8
8
  def initialize(key, opts={})
9
9
  @@client = Logdna::Client.new(key, opts)
10
- sleep 0.0001
10
+ sleep 0.01
11
11
  if @@client[:value] === Resources::LOGGER_NOT_CREATED
12
12
  @@client = nil
13
13
  puts "LogDNA logger not created"
@@ -39,7 +39,7 @@ module Logdna
39
39
  @actual_byte_limit = opts[:flushbyte] ||= Resources::FLUSH_BYTE_LIMIT
40
40
 
41
41
  @url = "#{Resources::ENDPOINT}?hostname=#{@qs[:hostname]}#{@qs[:mac]}#{@qs[:ip]}"
42
- @semaphore = Mutex.new
42
+ @@semaphore = Mutex.new
43
43
  begin
44
44
  @uri = URI(@url)
45
45
  rescue URI::ValidURIRequired => e
@@ -48,8 +48,8 @@ module Logdna
48
48
  return
49
49
  end
50
50
 
51
- @request = Net::HTTP::Post.new(@uri, 'Content-Type' => 'application/json')
52
- @request.basic_auth 'username', key
51
+ @@request = Net::HTTP::Post.new(@uri, 'Content-Type' => 'application/json')
52
+ @@request.basic_auth 'username', key
53
53
  self[:value] = Resources::LOGGER_CREATED
54
54
  end
55
55
  end
@@ -74,7 +74,7 @@ module Logdna
74
74
  rescue Encoding::UndefinedConversionError => e
75
75
  raise e
76
76
  end
77
- unless @semaphore.locked?
77
+ unless @@semaphore.locked?
78
78
  @currentbytesize += msg.bytesize
79
79
  @firstbuff.push({
80
80
  :line => msg,
@@ -103,25 +103,27 @@ module Logdna
103
103
  end
104
104
 
105
105
  def flush()
106
- @semaphore.synchronize {
107
- real = {:e => 'ls', :ls => @firstbuff }.to_json
108
- @request.body = real
109
- @response = Net::HTTP.start(@uri.hostname, @uri.port, :use_ssl => @uri.scheme == 'https') do |http|
110
- http.request(@request)
111
- end
112
- unless @firstbuff.empty?
113
- puts "Result: #{@response.body}"
114
- end
115
- @currentbytesize = @secondbytesize
116
- @secondbytesize = 0
117
- @firstbuff = []
118
- @firstbuff = @firstbuff + @secondbuff
119
- @secondbuff = []
120
- unless @task.nil?
121
- @task.shutdown
122
- @task.kill
123
- end
124
- }
106
+ if defined? @@request
107
+ @@semaphore.synchronize {
108
+ real = {:e => 'ls', :ls => @firstbuff }.to_json
109
+ @@request.body = real
110
+ @response = Net::HTTP.start(@uri.hostname, @uri.port, :use_ssl => @uri.scheme == 'https') do |http|
111
+ http.request(@@request)
112
+ end
113
+ unless @firstbuff.empty?
114
+ puts "Result: #{@response.body}"
115
+ end
116
+ @currentbytesize = @secondbytesize
117
+ @secondbytesize = 0
118
+ @firstbuff = []
119
+ @firstbuff = @firstbuff + @secondbuff
120
+ @secondbuff = []
121
+ unless @task.nil?
122
+ @task.shutdown
123
+ @task.kill
124
+ end
125
+ }
126
+ end
125
127
  end
126
128
 
127
129
  def exitout()
@@ -1,3 +1,3 @@
1
1
  module LogDNA
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
data/test.rb CHANGED
@@ -26,17 +26,9 @@ options4 = {
26
26
 
27
27
 
28
28
 
29
- logger = Logdna::Ruby.new('your-ingestion-key', options)
30
- logger.log('1No metadata, production env')
31
-
32
- logger = Logdna::Ruby.new('your-ingestion-key', options2)
33
- logger.log('2With metadata, staging env', {:meta => {:once => {:first => "nested1", :another => "nested2"}}, :level => "TRACE"})
34
-
35
- logger = Logdna::Ruby.new('your-ingestion-key', options3)
36
- logger.log('3No metadata, development env changed to production env', {:level => "TRACE", :env => "PRODUCTION"})
37
-
38
- logger = Logdna::Ruby.new('your-ingestion-key', options4)
39
- logger.log('4No metadata, no env')
29
+ logger = Logdna::Ruby.new('Your Ingestion Key', options);
30
+ logger.log('YOYO');
31
+ logger.log('EQWEJQWIOE');
40
32
 
41
33
 
42
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logdna
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gun Woo Choi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-26 00:00:00.000000000 Z
11
+ date: 2017-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -102,6 +102,7 @@ extra_rdoc_files: []
102
102
  files:
103
103
  - ".gitignore"
104
104
  - ".rspec"
105
+ - ".ruby-version"
105
106
  - Gemfile
106
107
  - LICENSE.txt
107
108
  - README.md