logdna 1.0.7 → 1.0.8

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: 63067e5a87e79680362915c0520ac9d5ed6f7001
4
- data.tar.gz: edb048fdc0ab14342306e9933cc287f71faa5491
3
+ metadata.gz: c55551804963d24df4eb0ea8582cce2043f0567d
4
+ data.tar.gz: 0e9aa46f633cfa23ebc9d9d13ce1203be38a6e59
5
5
  SHA512:
6
- metadata.gz: 75c4ba6c6e9c6626e1a63290719a279d9ea3c5d4e9074b7fefe17ec3fed9bd65e46d6e249a6464243f24d8fa927038987c9ee30f16f910d56edcd47c88a7c837
7
- data.tar.gz: 2583ed4acdef24334604e5cfad7b854d3042b5f097fdf30657dbe9125abf06e66ffa149cad325473d4d6ccf5b0e0079c6a141f88f39ceed82e51abd38589465c
6
+ metadata.gz: acd3e19e004f4b09a800558f2b82ed310fffedd2281829b6a7342492ff0fa403ac3ad4a9219797e44734d2da297b99546e1182bc74bce495cd11f541c91bc8f2
7
+ data.tar.gz: d90c07c141bb8a0ad76fe035177349db15d7a332c9d91081731aee278db55e3ed1c6b3e284d717530595bb671801d48edae2656f44560b4982d20cb92952459b
data/lib/logdna.rb CHANGED
@@ -22,7 +22,7 @@ module Logdna
22
22
  end
23
23
  end
24
24
 
25
- def log(msg, opts={})
25
+ def log(msg=nil, opts={})
26
26
  if @level || @app || @env
27
27
  @@client.change(@level, @app, @env)
28
28
  @level = nil
@@ -35,42 +35,42 @@ module Logdna
35
35
  'Saved'
36
36
  end
37
37
 
38
- def trace(msg, opts={})
38
+ def trace(msg=nil, opts={})
39
39
  opts[:level] = "TRACE"
40
40
  loggerExist?
41
41
  @response = @@client.tobuffer(msg, opts)
42
42
  'Saved'
43
43
  end
44
44
 
45
- def debug(msg, opts={})
45
+ def debug(msg=nil, opts={})
46
46
  opts[:level] = "DEBUG"
47
47
  loggerExist?
48
48
  @response = @@client.tobuffer(msg, opts)
49
49
  'Saved'
50
50
  end
51
51
 
52
- def info(msg, opts={})
52
+ def info(msg=nil, opts={})
53
53
  opts[:level] = "INFO"
54
54
  loggerExist?
55
55
  @response = @@client.tobuffer(msg, opts)
56
56
  'Saved'
57
57
  end
58
58
 
59
- def warn(msg, opts={})
59
+ def warn(msg=nil, opts={})
60
60
  opts[:level] = "WARN"
61
61
  loggerExist?
62
62
  @response = @@client.tobuffer(msg, opts)
63
63
  'Saved'
64
64
  end
65
65
 
66
- def error(msg, opts={})
66
+ def error(msg=nil, opts={})
67
67
  opts[:level] = "ERROR"
68
68
  loggerExist?
69
69
  @response = @@client.tobuffer(msg, opts)
70
70
  'Saved'
71
71
  end
72
72
 
73
- def fatal(msg, opts={})
73
+ def fatal(msg=nil, opts={})
74
74
  opts[:level] = "FATAL"
75
75
  loggerExist?
76
76
  @response = @@client.tobuffer(msg, opts)
@@ -139,9 +139,11 @@ module Logdna
139
139
  return comparedTo == @level.upcase
140
140
  end
141
141
 
142
- def <<(*arg)
143
- puts "<< not supported in LogDNA logger"
144
- return false
142
+ def <<(msg=nil, opts={})
143
+ opts[:level] = ""
144
+ loggerExist?
145
+ @response = @@client.tobuffer(msg, opts)
146
+ 'Saved'
145
147
  end
146
148
 
147
149
  def add(*arg)
@@ -149,9 +151,11 @@ module Logdna
149
151
  return false
150
152
  end
151
153
 
152
- def unknown(*arg)
153
- puts "unknown not supported in LogDNA logger"
154
- return false
154
+ def unknown(msg=nil, opts={})
155
+ opts[:level] = "UNKNOWN"
156
+ loggerExist?
157
+ @response = @@client.tobuffer(msg, opts)
158
+ 'Saved'
155
159
  end
156
160
 
157
161
  def datetime_format(*arg)
data/lib/logdna/client.rb CHANGED
@@ -74,51 +74,52 @@ module Logdna
74
74
  end
75
75
 
76
76
  def tobuffer(msg, opts)
77
- if @task
78
- unless @task.running?
77
+ unless msg.nil?
78
+ if @task
79
+ unless @task.running?
80
+ @task = Concurrent::TimerTask.new(execution_interval: @actual_flush_interval, timeout_interval: Resources::TIMER_OUT){ flush() }
81
+ @task.execute
82
+ end
83
+ else
79
84
  @task = Concurrent::TimerTask.new(execution_interval: @actual_flush_interval, timeout_interval: Resources::TIMER_OUT){ flush() }
80
85
  @task.execute
81
86
  end
82
- else
83
- @task = Concurrent::TimerTask.new(execution_interval: @actual_flush_interval, timeout_interval: Resources::TIMER_OUT){ flush() }
84
- @task.execute
85
- end
86
87
 
87
- unless msg.instance_of? String
88
- msg = msg.to_s
89
- end
88
+ unless msg.instance_of? String
89
+ msg = msg.to_s
90
+ end
90
91
 
91
- begin
92
- msg = msg.encode("UTF-8")
93
- rescue Encoding::UndefinedConversionError => e
94
- raise e
95
- end
96
- unless @@semaphore.locked?
97
- @currentbytesize += msg.bytesize
98
- @firstbuff.push({
99
- :line => msg,
100
- :app => opts[:app] ||= @qs[:app],
101
- :level => opts[:level] ||= @qs[:level],
102
- :timestamp => Time.now.to_i,
103
- :meta => opts[:meta] ||= nil,
104
- :env => (opts[:env]) ? opts[:env] : (@qs[:env]) ? @qs[:env] : nil
105
- }.reject { |k,v| k === :meta && v.nil? })
106
- else
107
- @secondbytesize += msg.bytesize
108
- @secondbuff.push({
109
- :line => msg,
110
- :app => opts[:app] ||= @qs[:app],
111
- :level => opts[:level] ||= @qs[:level],
112
- :timestamp => Time.now.to_i,
113
- :meta => opts[:meta] ||= nil,
114
- :env => (opts[:env]) ? opts[:env] : (@qs[:env]) ? @qs[:env] : nil
115
- }.reject { |k,v| k === :meta && v.nil? })
116
- end
92
+ begin
93
+ msg = msg.encode("UTF-8")
94
+ rescue Encoding::UndefinedConversionError => e
95
+ raise e
96
+ end
97
+ unless @@semaphore.locked?
98
+ @currentbytesize += msg.bytesize
99
+ @firstbuff.push({
100
+ :line => msg,
101
+ :app => opts[:app] ||= @qs[:app],
102
+ :level => opts[:level] ||= @qs[:level],
103
+ :timestamp => Time.now.to_i,
104
+ :meta => opts[:meta] ||= nil,
105
+ :env => (opts[:env]) ? opts[:env] : (@qs[:env]) ? @qs[:env] : nil
106
+ }.reject { |k,v| k === :meta && v.nil? })
107
+ else
108
+ @secondbytesize += msg.bytesize
109
+ @secondbuff.push({
110
+ :line => msg,
111
+ :app => opts[:app] ||= @qs[:app],
112
+ :level => opts[:level] ||= @qs[:level],
113
+ :timestamp => Time.now.to_i,
114
+ :meta => opts[:meta] ||= nil,
115
+ :env => (opts[:env]) ? opts[:env] : (@qs[:env]) ? @qs[:env] : nil
116
+ }.reject { |k,v| k === :meta && v.nil? })
117
+ end
117
118
 
118
- if @actual_byte_limit < @currentbytesize
119
- flush()
119
+ if @actual_byte_limit < @currentbytesize
120
+ flush()
121
+ end
120
122
  end
121
-
122
123
  end
123
124
 
124
125
  def flush()
@@ -1,3 +1,3 @@
1
1
  module LogDNA
2
- VERSION = '1.0.7'.freeze
2
+ VERSION = '1.0.8'.freeze
3
3
  end
data/test.rb CHANGED
@@ -2,10 +2,10 @@ require 'require_all'
2
2
  require_all 'lib'
3
3
 
4
4
 
5
- options = {hostname: "yondfsoikplghjniodhnfvreulwignfewfnrleuwinf"}
5
+ options = {hostname: "new"}
6
6
 
7
7
 
8
- logger1 = Logdna::Ruby.new('Your ingestion key', options)
8
+ logger1 = Logdna::Ruby.new('Your API Key', options)
9
9
 
10
10
  logger1.level = Logger::TRACE
11
11
  logger1.log('is this trace')
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.7
4
+ version: 1.0.8
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-31 00:00:00.000000000 Z
11
+ date: 2017-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby