logdna 1.3.0 → 1.4.0

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: 4b6d490f2946fb1865ea42c2173c67bb1334cd86
4
- data.tar.gz: fa0172a11376438db312bf4f292d22e39a6f2d6b
3
+ metadata.gz: e53a67887ce8f0010133800e0e1846eef1c9d203
4
+ data.tar.gz: 1b5ab91a81414693bb8a9d98860038cceacaa780
5
5
  SHA512:
6
- metadata.gz: 01f9b8b658b15efd35361ab6d6a92ce7f20ce761a5945f646d12430888bd60c37a9330e83f8dde8e3d2e5ab5d7ab3f4c512fe0e122b5492d5f1eb9b14cfed14d
7
- data.tar.gz: 175a0d1a5efad591e3b3707e47185d47c0a0af5f19bfbbb5739aecf44445cf93e81170c106d972a14b6e0eb3ec733cb9039d70a9b1ce0df26d9d65309b9cbc20
6
+ metadata.gz: c8e2d906aaeeecaa01e0340af6d88c16fb01343b06ec4ac91c8450c3975590048f03bf44f68b942058e4d69125a344f3c65ec65d4e8c261b7e2134a29b6c07db
7
+ data.tar.gz: def81ac988ce294d3e73d8c2f03698c8c5e27a7eed741d1e091c0eea6579dfaa722a98842ef42d70c54a45cbbf5fd9dc20f98dc287e03989e7004e8249138f56
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 edwin-lai
3
+ Copyright (c) 2019 LogDNA
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -81,7 +81,6 @@ Clear current metadata, level, appname, environment
81
81
  logger.clear
82
82
 
83
83
  Check current log level:
84
-
85
84
  logger.info? => true
86
85
  logger.warn? => false
87
86
 
@@ -94,11 +93,19 @@ Log a message with a particular level easily
94
93
 
95
94
  Hostname and app name cannot be more than 80 characters.
96
95
 
96
+ ### Rails Setup
97
+ In your `config/environments/environment.rb`:
98
+
99
+ ```
100
+ Rails.application.configure do
101
+ config.logger = Logdna::Ruby.new(your_api_key, options)
102
+ end
103
+ ```
97
104
 
98
105
  # Important Notes
99
106
 
100
107
  1. This logger assumes that you pass in json formatted data
101
- 2. This logger is a singleton (do not create mutiple instances of the logger) even though the singleton structure is not strongly enforced.
108
+ 2. This logger is a singleton (do not create mutiple instances of the logger) even though the singleton structure is not strongly enforced.
102
109
 
103
110
  # API
104
111
 
@@ -119,7 +126,7 @@ Instantiates a new instance of the class it is called on. ingestion_key is requi
119
126
  |{ :flushtime => Log flush interval in seconds } | 0.25 seconds |
120
127
  |{ :flushbyte => Log flush upper limit in bytes } | 500000 bytes ~= 0.5 megabytes |
121
128
 
122
- Different log level displays log messages in different colors as well.
129
+ Different log level displays log messages in different colors as well.
123
130
  - ![TRACE DEBUG INFO Colors](https://placehold.it/15/515151/000000?text=+) "Trace" "Debug" "Info"
124
131
  - ![WARN Color](https://placehold.it/15/ec9563/000000?text=+) "Warn"
125
132
  - ![ERROR Fatal Colors](https://placehold.it/15/e37e7d/000000?text=+) "Error" "Fatal"
@@ -1,10 +1,12 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
- # require 'singleton'
4
- require 'socket'
5
- require 'uri'
6
- require_relative 'logdna/client.rb'
7
- require_relative 'logdna/resources.rb'
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+ require "socket"
5
+ require "uri"
6
+ require_relative "logdna/client.rb"
7
+ require_relative "logdna/resources.rb"
8
+ require_relative "logdna/version.rb"
9
+
8
10
  module Logdna
9
11
  class ValidURLRequired < ArgumentError; end
10
12
  class MaxLengthExceeded < ArgumentError; end
@@ -13,61 +15,38 @@ module Logdna
13
15
  # uncomment line below and line 3 to enforce singleton
14
16
  # include Singleton
15
17
  Logger::TRACE = 5
16
- attr_accessor :level, :app, :env, :meta
18
+ attr_accessor :app, :env, :meta
17
19
 
18
- def initialize(key, opts={})
19
- @app = opts[:app] || 'default'
20
- @level = opts[:level] || 'INFO'
20
+ def initialize(key, opts = {})
21
+ @app = opts[:app] || "default"
22
+ @log_level = opts[:level] || "INFO"
21
23
  @env = opts[:env]
22
24
  @meta = opts[:meta]
23
- @@client = nil unless defined? @@client
24
-
25
+ @internal_logger = Logger.new(STDOUT)
26
+ @internal_logger.level = Logger::DEBUG
25
27
  endpoint = opts[:endpoint] || Resources::ENDPOINT
26
28
  hostname = opts[:hostname] || Socket.gethostname
27
- ip = opts.key?(:ip) ? "&ip=#{opts[:ip]}" : ''
28
- mac = opts.key?(:mac) ? "&mac=#{opts[:mac]}" : ''
29
- url = "#{endpoint}?hostname=#{hostname}#{mac}#{ip}"
30
-
31
- begin
32
- if (hostname.size > Resources::MAX_INPUT_LENGTH || @app.size > Resources::MAX_INPUT_LENGTH )
33
- raise MaxLengthExceeded.new
34
- end
35
- rescue MaxLengthExceeded => e
36
- puts "Hostname or Appname is over #{Resources::MAX_INPUT_LENGTH} characters"
37
- handle_exception(e)
38
- return
39
- end
40
29
 
41
- begin
42
- uri = URI(url)
43
- rescue URI::ValidURIRequired => e
44
- puts "Invalid URL Endpoint: #{url}"
45
- handle_exception(e)
30
+ if hostname.size > Resources::MAX_INPUT_LENGTH || @app.size > Resources::MAX_INPUT_LENGTH
31
+ @internal_logger.debug("Hostname or Appname is over #{Resources::MAX_INPUT_LENGTH} characters")
46
32
  return
47
33
  end
48
34
 
49
- begin
50
- request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')
51
- request.basic_auth 'username', key
52
- rescue => e
53
- handle_exception(e)
54
- return
55
- end
56
-
57
- @@client = Logdna::Client.new(request, uri, opts)
58
- end
35
+ ip = opts.key?(:ip) ? "&ip=#{opts[:ip]}" : ""
36
+ mac = opts.key?(:mac) ? "&mac=#{opts[:mac]}" : ""
37
+ url = "#{endpoint}?hostname=#{hostname}#{mac}#{ip}"
38
+ uri = URI(url)
59
39
 
60
- def handle_exception(e)
61
- exception_message = e.message
62
- exception_backtrace = e.backtrace
63
- # NOTE: should log with Ruby logger?
64
- puts exception_message
40
+ request = Net::HTTP::Post.new(uri.request_uri, "Content-Type" => "application/json")
41
+ request.basic_auth("username", key)
42
+ request[:'user-agent'] = opts[:'user-agent'] || "ruby/#{LogDNA::VERSION}"
43
+ @client = Logdna::Client.new(request, uri, opts)
65
44
  end
66
45
 
67
46
  def default_opts
68
47
  {
69
48
  app: @app,
70
- level: @level,
49
+ level: @log_level,
71
50
  env: @env,
72
51
  meta: @meta,
73
52
  }
@@ -75,85 +54,78 @@ module Logdna
75
54
 
76
55
  def level=(value)
77
56
  if value.is_a? Numeric
78
- @level = Resources::LOG_LEVELS[value]
57
+ @log_level = Resources::LOG_LEVELS[value]
79
58
  return
80
59
  end
81
60
 
82
- @level = value
61
+ @log_level = value
83
62
  end
84
63
 
85
- def log(msg=nil, opts={})
86
- loggerExist?
87
- message = msg
88
- message = yield if msg.nil? && block_given?
89
- @response = @@client.buffer(message, default_opts.merge(opts).merge({
90
- timestamp: (Time.now.to_f * 1000).to_i
91
- }))
92
- 'Saved'
64
+ def log(message = nil, opts = {})
65
+ if message.nil? && block_given?
66
+ message = yield
67
+ end
68
+ if message.nil?
69
+ @internal_logger.debug("provide either a message or block")
70
+ return
71
+ end
72
+ message = message.to_s.encode("UTF-8")
73
+ @client.write_to_buffer(message, default_opts.merge(opts).merge(
74
+ timestamp: (Time.now.to_f * 1000).to_i
75
+ ))
93
76
  end
94
77
 
95
78
  Resources::LOG_LEVELS.each do |lvl|
96
79
  name = lvl.downcase
97
80
 
98
- define_method name do |msg=nil, opts={}, &block|
99
- self.log(msg, opts.merge({
100
- level: lvl,
101
- }), &block)
81
+ define_method name do |msg = nil, opts = {}, &block|
82
+ self.log(msg, opts.merge(
83
+ level: lvl
84
+ ), &block)
102
85
  end
103
86
 
104
87
  define_method "#{name}?" do
105
- return Resources::LOG_LEVELS[self.level] == lvl if self.level.is_a? Numeric
88
+ return Resources::LOG_LEVELS[self.level] == lvl if level.is_a? Numeric
89
+
106
90
  self.level == lvl
107
91
  end
108
92
  end
109
93
 
110
94
  def clear
111
- @app = 'default'
112
- @level = 'INFO'
95
+ @app = "default"
96
+ @log_level = "INFO"
113
97
  @env = nil
114
98
  @meta = nil
115
99
  end
116
100
 
117
- def loggerExist?
118
- if @@client.nil?
119
- puts "Logger Not Initialized Yet"
120
- close
121
- end
122
- end
123
-
124
- def <<(msg=nil, opts={})
125
- self.log(msg, opts.merge({
126
- level: '',
127
- }))
101
+ def <<(msg = nil, opts = {})
102
+ log(msg, opts.merge(
103
+ level: ""
104
+ ))
128
105
  end
129
106
 
130
- def add(*arg)
131
- puts "add not supported in LogDNA logger"
132
- return false
107
+ def add(*_arg)
108
+ @internal_logger.debug("add not supported in LogDNA logger")
109
+ false
133
110
  end
134
111
 
135
- def unknown(msg=nil, opts={})
136
- self.log(msg, opts.merge({
137
- level: 'UNKNOWN',
138
- }))
112
+ def unknown(msg = nil, opts = {})
113
+ log(msg, opts.merge(
114
+ level: "UNKNOWN"
115
+ ))
139
116
  end
140
117
 
141
- def datetime_format(*arg)
142
- puts "datetime_format not supported in LogDNA logger"
143
- return false
118
+ def datetime_format(*_arg)
119
+ @internal_logger.debug("datetime_format not supported in LogDNA logger")
120
+ false
144
121
  end
145
122
 
146
-
147
123
  def close
148
- if defined? @@client and !@@client.nil?
149
- @@client.exitout()
150
- end
124
+ @client&.exitout
151
125
  end
152
126
 
153
127
  at_exit do
154
- if defined? @@client and !@@client.nil?
155
- @@client.exitout()
156
- end
128
+ @client&.exitout
157
129
  end
158
130
  end
159
131
  end
@@ -1,47 +1,38 @@
1
- require 'net/http'
2
- require 'socket'
3
- require 'json'
4
- require 'concurrent'
5
- require 'thread'
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "socket"
5
+ require "json"
6
+ require "concurrent"
7
+ require "date"
6
8
 
7
9
  module Logdna
8
10
  class Client
9
-
10
11
  def initialize(request, uri, opts)
11
12
  @uri = uri
12
13
 
13
14
  # NOTE: buffer is in memory
14
- @buffer = StringIO.new
15
- @messages = []
16
- @buffer_over_limit = false
15
+ @buffer = []
16
+ @buffer_byte_size = 0
17
17
 
18
- @side_buffer = StringIO.new
19
18
  @side_messages = []
20
19
 
21
20
  @lock = Mutex.new
22
- @task = nil
21
+ @side_message_lock = Mutex.new
22
+ @flush_limit = opts[:flush_size] || Resources::FLUSH_BYTE_LIMIT
23
+ @flush_interval = opts[:flush_interval] || Resources::FLUSH_INTERVAL
24
+ @flush_scheduled = false
25
+ @exception_flag = false
23
26
 
24
- # NOTE: the byte limit only affects the message, not the entire message_hash
25
- @actual_byte_limit = opts[:flushbyte] ||= Resources::FLUSH_BYTE_LIMIT
26
- @actual_flush_interval = opts[:flushtime] ||= Resources::FLUSH_INTERVAL
27
+ @request = request
28
+ @retry_timeout = opts[:retry_timeout] || Resources::RETRY_TIMEOUT
27
29
 
28
- @@request = request
30
+ @internal_logger = Logger.new(STDOUT)
31
+ @internal_logger.level = Logger::DEBUG
29
32
  end
30
33
 
31
- def encode_message(msg)
32
- msg = msg.to_s unless msg.instance_of? String
33
-
34
- begin
35
- msg = msg.encode("UTF-8")
36
- rescue Encoding::UndefinedConversionError => e
37
- # NOTE: should this be raised or handled silently?
38
- # raise e
39
- end
40
- msg
41
- end
42
-
43
- def message_hash(msg, opts={})
44
- obj = {
34
+ def process_message(msg, opts = {})
35
+ processed_message = {
45
36
  line: msg,
46
37
  app: opts[:app],
47
38
  level: opts[:level],
@@ -49,116 +40,100 @@ module Logdna
49
40
  meta: opts[:meta],
50
41
  timestamp: Time.now.to_i,
51
42
  }
52
- obj.delete(:meta) if obj[:meta].nil?
53
- obj
43
+ processed_message.delete(:meta) if processed_message[:meta].nil?
44
+ processed_message
54
45
  end
55
46
 
56
- def create_flush_task
57
- return @task unless @task.nil? or !@task.running?
47
+ def schedule_flush
48
+ start_timer = lambda {
49
+ sleep(@exception_flag ? @retry_timeout : @flush_interval)
50
+ flush if @flush_scheduled
51
+ }
52
+ thread = Thread.new { start_timer.call }
53
+ thread.join
54
+ end
58
55
 
59
- t = Concurrent::TimerTask.new(execution_interval: @actual_flush_interval, timeout_interval: Resources::TIMER_OUT) do |task|
60
- if @messages.any?
61
- # keep running if there are queued messages, but don't flush
62
- # because the buffer is being flushed due to being over the limit
63
- unless @buffer_over_limit
64
- flush()
65
- end
56
+ def write_to_buffer(msg, opts)
57
+ if @lock.try_lock
58
+ processed_message = process_message(msg, opts)
59
+ new_message_size = processed_message.to_s.bytesize
60
+ @buffer.push(processed_message)
61
+ @buffer_byte_size += new_message_size
62
+ @flush_scheduled = true
63
+ @lock.unlock
64
+
65
+ if @flush_limit <= @buffer_byte_size
66
+ flush
66
67
  else
67
- # no messages means we can kill the task
68
- task.kill
68
+ schedule_flush
69
+ end
70
+ else
71
+ @side_message_lock.synchronize do
72
+ @side_messages.push(process_message(msg, opts))
69
73
  end
70
- end
71
- t.execute
72
- end
73
-
74
- def check_side_buffer
75
- return if @side_buffer.size == 0
76
-
77
- @buffer.write(@side_buffer.string)
78
- @side_buffer.truncate(0)
79
- queued_side_messages = @side_messages
80
- @side_messages = []
81
- queued_side_messages.each { |message_hash_obj| @messages.push(message_hash_obj) }
82
- end
83
-
84
-
85
- # this should always be running synchronously within this thread
86
- def buffer(msg, opts)
87
- buffer_size = write_to_buffer(msg, opts)
88
- unless buffer_size.nil?
89
- process_buffer(buffer_size)
90
74
  end
91
75
  end
92
76
 
93
- def write_to_buffer(msg, opts)
94
- return if msg.nil?
95
- msg = encode_message(msg)
96
-
97
- if @lock.locked?
98
- @side_buffer.write(msg)
99
- @side_messages.push(message_hash(msg, opts))
100
- return
77
+ # This method has to be called with @lock
78
+ def send_request
79
+ @side_message_lock.synchronize do
80
+ @buffer.concat(@side_messages)
81
+ @side_messages.clear
101
82
  end
102
83
 
103
- check_side_buffer
104
- buffer_size = @buffer.write(msg)
105
- @messages.push(message_hash(msg, opts))
106
- buffer_size
107
- end
84
+ @request.body = {
85
+ e: "ls",
86
+ ls: @buffer
87
+ }.to_json
108
88
 
109
- def queue_to_buffer(queue=@queue)
110
- next_object = queue.shift
111
- write_to_buffer(next_object[:msg], next_object[:opts])
112
- end
113
-
114
- def process_buffer(buffer_size)
115
- if buffer_size > @actual_byte_limit
116
- @buffer_over_limit = true
117
- flush()
118
- @buffer_over_limit = false
119
- else
120
- @task = create_flush_task
89
+ handle_exception = lambda do |message|
90
+ @internal_logger.debug(message)
91
+ @exception_flag = true
92
+ @side_message_lock.synchronize do
93
+ @side_messages.concat(@buffer)
94
+ end
121
95
  end
122
- end
123
96
 
124
- # this should be running synchronously if @buffer_over_limit i.e. called from self.buffer
125
- # else asynchronously through @task
126
- def flush()
127
- if defined? @@request and !@@request.nil?
128
- request_messages = []
129
- @lock.synchronize do
130
- request_messages = @messages
131
- @buffer.truncate(0)
132
- @messages = []
97
+ begin
98
+ @response = Net::HTTP.start(
99
+ @uri.hostname,
100
+ @uri.port,
101
+ use_ssl: @uri.scheme == "https"
102
+ ) do |http|
103
+ http.request(@request)
133
104
  end
134
- return if request_messages.empty?
135
-
136
- real = {
137
- e: 'ls',
138
- ls: request_messages,
139
- }.to_json
140
-
141
- @@request.body = real
142
- @response = Net::HTTP.start(@uri.hostname, @uri.port, use_ssl: @uri.scheme == 'https') do |http|
143
- http.request(@@request)
105
+ if @response.is_a?(Net::HTTPForbidden)
106
+ @internal_logger.debug("Please provide a valid ingestion key")
107
+ elsif !@response.is_a?(Net::HTTPSuccess)
108
+ handle_exception.call("The response is not successful #{@response}")
144
109
  end
110
+ @exception_flag = false
111
+ rescue SocketError
112
+ handle_exception.call("Network connectivity issue")
113
+ rescue Errno::ECONNREFUSED => e
114
+ handle_exception.call("The server is down. #{e.message}")
115
+ rescue Timeout::Error => e
116
+ handle_exception.call("Timeout error occurred. #{e.message}")
117
+ ensure
118
+ @buffer.clear
119
+ end
120
+ end
145
121
 
146
- # don't kill @task if this was executed from self.buffer
147
- # don't kill @task if there are queued messages
148
- unless @buffer_over_limit || @messages.any? || @task.nil?
149
- @task.shutdown
150
- @task.kill
122
+ def flush
123
+ if @lock.try_lock
124
+ @flush_scheduled = false
125
+ if @buffer.any? || @side_messages.any?
126
+ send_request
151
127
  end
128
+ @lock.unlock
129
+ else
130
+ schedule_flush
152
131
  end
153
132
  end
154
133
 
155
- def exitout()
156
- check_side_buffer
157
- if @messages.any?
158
- flush()
159
- end
160
- puts "Exiting LogDNA logger: Logging remaining messages"
161
- return
134
+ def exitout
135
+ flush
136
+ @internal_logger.debug("Exiting LogDNA logger: Logging remaining messages")
162
137
  end
163
138
  end
164
139
  end
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Resources
2
- LOG_LEVELS = ['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL', 'TRACE'].freeze
3
- DEFAULT_REQUEST_HEADER = { 'Content-Type' => 'application/json; charset=UTF-8' }.freeze
4
- DEFAULT_REQUEST_TIMEOUT = 180000
5
- MS_IN_A_DAY = 86400000
6
- MAX_REQUEST_TIMEOUT = 300000
7
- MAX_LINE_LENGTH = 32000
4
+ LOG_LEVELS = %w[DEBUG INFO WARN ERROR FATAL TRACE].freeze
5
+ DEFAULT_REQUEST_HEADER = { "Content-Type" => "application/json; charset=UTF-8" }.freeze
6
+ DEFAULT_REQUEST_TIMEOUT = 180_000
7
+ MS_IN_A_DAY = 86_400_000
8
+ MAX_REQUEST_TIMEOUT = 300_000
9
+ MAX_LINE_LENGTH = 32_000
8
10
  MAX_INPUT_LENGTH = 80
11
+ RETRY_TIMEOUT = 60
9
12
  FLUSH_INTERVAL = 0.25
10
- TIMER_OUT = 15
11
- FLUSH_BYTE_LIMIT = 500000
12
- ENDPOINT = 'https://logs.logdna.com/logs/ingest'.freeze
13
- MAC_ADDR_CHECK = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/
14
- IP_ADDR_CHECK = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
13
+ FLUSH_BYTE_LIMIT = 500_000
14
+ ENDPOINT = "https://logs.logdna.com/logs/ingest"
15
+ MAC_ADDR_CHECK = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/.freeze
16
+ IP_ADDR_CHECK = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.freeze
15
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LogDNA
2
- VERSION = '1.3.0'.freeze
4
+ VERSION = "1.4.0"
3
5
  end
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.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
- - Gun Woo Choi, Derek Zhou
7
+ - Gun Woo Choi, Derek Zhou, Vilya Levitskiy, Muaz Siddiqui
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-04 00:00:00.000000000 Z
11
+ date: 2020-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: require_all
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.4'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.4'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: json
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,80 +39,45 @@ dependencies:
53
39
  - !ruby/object:Gem::Version
54
40
  version: '2.0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.13'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.13'
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '10.5'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '10.5'
83
- - !ruby/object:Gem::Dependency
84
- name: rspec
42
+ name: require_all
85
43
  requirement: !ruby/object:Gem::Requirement
86
44
  requirements:
87
45
  - - "~>"
88
46
  - !ruby/object:Gem::Version
89
- version: '3.5'
90
- type: :development
47
+ version: '1.4'
48
+ type: :runtime
91
49
  prerelease: false
92
50
  version_requirements: !ruby/object:Gem::Requirement
93
51
  requirements:
94
52
  - - "~>"
95
53
  - !ruby/object:Gem::Version
96
- version: '3.5'
54
+ version: '1.4'
97
55
  - !ruby/object:Gem::Dependency
98
- name: webmock
56
+ name: rubocop
99
57
  requirement: !ruby/object:Gem::Requirement
100
58
  requirements:
101
59
  - - "~>"
102
60
  - !ruby/object:Gem::Version
103
- version: '2.3'
61
+ version: '0.78'
104
62
  type: :development
105
63
  prerelease: false
106
64
  version_requirements: !ruby/object:Gem::Requirement
107
65
  requirements:
108
66
  - - "~>"
109
67
  - !ruby/object:Gem::Version
110
- version: '2.3'
68
+ version: '0.78'
111
69
  description:
112
70
  email: support@logdna.com
113
71
  executables: []
114
72
  extensions: []
115
73
  extra_rdoc_files: []
116
74
  files:
117
- - ".gitignore"
118
- - ".rspec"
119
- - ".ruby-version"
120
- - Gemfile
121
- - LICENSE.txt
75
+ - LICENSE
122
76
  - README.md
123
- - Rakefile
124
77
  - lib/logdna.rb
125
78
  - lib/logdna/client.rb
126
79
  - lib/logdna/resources.rb
127
80
  - lib/logdna/version.rb
128
- - logdna.gemspec
129
- - test.rb
130
81
  homepage: https://github.com/logdna/ruby
131
82
  licenses:
132
83
  - MIT
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.gem
11
- .DS_Store
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
@@ -1 +0,0 @@
1
- 2.2.0
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in logdna_ruby.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,32 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'logdna/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'logdna'
8
- spec.version = LogDNA::VERSION
9
- spec.authors = 'Gun Woo Choi, Derek Zhou'
10
- spec.email = 'support@logdna.com'
11
-
12
- spec.summary = 'LogDNA Ruby logger'
13
- spec.homepage = 'https://github.com/logdna/ruby'
14
- spec.license = 'MIT'
15
-
16
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
18
- end
19
- spec.bindir = 'exe'
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ['lib']
22
-
23
-
24
- spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
25
- spec.add_runtime_dependency 'require_all', '~> 1.4'
26
- spec.add_runtime_dependency 'json', '~> 2.0'
27
-
28
- spec.add_development_dependency 'bundler', '~> 1.13'
29
- spec.add_development_dependency 'rake', '~> 10.5'
30
- spec.add_development_dependency 'rspec', '~> 3.5'
31
- spec.add_development_dependency 'webmock', '~> 2.3'
32
- end
data/test.rb DELETED
@@ -1,69 +0,0 @@
1
- require 'require_all'
2
- require_all 'lib'
3
-
4
-
5
- options = {hostname: "new_ruby", meta:{:once => {:first => "nested1", :another => "nested2"}}}
6
-
7
-
8
- logger1 = Logdna::Ruby.new('Your API Key', options)
9
-
10
- logger1.log('**************** This is the start of test ****************')
11
- logger1.env = 'STAGING'
12
- logger1.app = 'HELLO'
13
- logger1.warn('Warn message with Staging and Hello')
14
- logger1.clear
15
- logger1.log('Is everything back to normal?')
16
-
17
-
18
- logger1.log('Testing env app name change using log')
19
- logger1.env = 'PRODUCTION'
20
- logger1.app = 'CHANGED'
21
- logger1.log('This should be stage = PRODUCTION and appname = CHANGED')
22
- logger1.log('Testing env app name change using other messages')
23
-
24
-
25
- logger1.error('This is error message with env = DEVELOPMENT and appname = NIHAO', {:env => 'DEVELOPMENT', :app => 'NIHAO'})
26
- logger1.log('Should not stay as DEVELOPMENT and NIHAO')
27
- logger1.env = 'DEVELOPMENT'
28
- logger1.app = 'NIHAO'
29
- logger1.log('Now should be DEVELOPMENT and NIHAO')
30
- logger1.log('Logging metadata in trace level', {:meta => {:once => {:first => "nested1", :another => "nested2"}}, :level => "TRACE"})
31
-
32
-
33
- logger1.level = Logger::DEBUG
34
- logger1.log('This is debug message')
35
- logger1.add('this should not be supported')
36
- logger1.fatal('Does this continue as fatal?')
37
- logger1.log('This should be debug')
38
- logger1.level = Logger::WARN
39
- logger1.log('**************** This is the end of test ****************')
40
-
41
-
42
- =begin
43
- logger1.level = Logger::WARN
44
- logger1.log('This should be warn')
45
- logger1.trace('This should be trace')
46
- logger1.log('Again warn level')
47
-
48
- logger1.log('Warn level log1')
49
- logger1.info('Info level log1')
50
- logger1.level = Logger::DEBUG
51
- logger1.log('DEBUG log1')
52
-
53
- logger1.app = 'NEW APP NAME'
54
- logger1.env = 'Staging'
55
- logger1.level = 'INFO'
56
-
57
-
58
-
59
- logger1.level = 'INFO'
60
- logger1.level == Logger::INFO
61
-
62
-
63
- logger1.log('are changes all updated')
64
- =end
65
- sleep 3
66
-
67
-
68
-
69
-