logdna 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logdna.rb +76 -1
- data/lib/logdna/client.rb +15 -0
- data/lib/logdna/resources.rb +1 -1
- data/lib/logdna/version.rb +1 -1
- data/test.rb +15 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 394ed1eb0fcbf401b7772034a2b4dcbe36dfcd3f
|
4
|
+
data.tar.gz: 38443b4682659a71e2796760a89dfa7e3309f1ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd7bb549b3c864bdd95f1b4af5fbc7210c4547624dbbe8fbe221e7c4ce779eaa8102f960d852961195f5fbf43351e7347ba650ba28fa7148311d3cda4b23f379
|
7
|
+
data.tar.gz: '089b7de0b866804472b1304eadc64f6008cc97434465f60f60a8e8379e3d8e40fdf6f777488df1983ed268ab7c33b3e6f2d726aa430bdf8f18d5d4e559d5c042'
|
data/lib/logdna.rb
CHANGED
@@ -5,6 +5,11 @@ require_relative 'logdna/client.rb'
|
|
5
5
|
require_relative 'logdna/resources.rb'
|
6
6
|
module Logdna
|
7
7
|
class Ruby
|
8
|
+
attr_accessor :level, :app, :env
|
9
|
+
@level = nil
|
10
|
+
@app = nil
|
11
|
+
@env = nil
|
12
|
+
|
8
13
|
def initialize(key, opts={})
|
9
14
|
@@client = Logdna::Client.new(key, opts)
|
10
15
|
sleep 0.01
|
@@ -16,7 +21,75 @@ module Logdna
|
|
16
21
|
end
|
17
22
|
|
18
23
|
def log(msg, opts={})
|
19
|
-
if
|
24
|
+
if @level || @app || @env
|
25
|
+
@@client.change(@level, @app, @env)
|
26
|
+
@level = nil
|
27
|
+
@app = nil
|
28
|
+
@env = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
if @@client.nil?
|
32
|
+
puts "Logger Not Initialized Yet"
|
33
|
+
return
|
34
|
+
end
|
35
|
+
@response = @@client.tobuffer(msg, opts)
|
36
|
+
'Saved'
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def trace(msg, opts={})
|
41
|
+
opts[:level] = "TRACE"
|
42
|
+
if @@client.nil?
|
43
|
+
puts "Logger Not Initialized Yet"
|
44
|
+
return
|
45
|
+
end
|
46
|
+
@response = @@client.tobuffer(msg, opts)
|
47
|
+
'Saved'
|
48
|
+
end
|
49
|
+
|
50
|
+
def debug(msg, opts={})
|
51
|
+
opts[:level] = "DEBUG"
|
52
|
+
if @@client.nil?
|
53
|
+
puts "Logger Not Initialized Yet"
|
54
|
+
return
|
55
|
+
end
|
56
|
+
@response = @@client.tobuffer(msg, opts)
|
57
|
+
'Saved'
|
58
|
+
end
|
59
|
+
|
60
|
+
def info(msg, opts={})
|
61
|
+
opts[:level] = "INFO"
|
62
|
+
if @@client.nil?
|
63
|
+
puts "Logger Not Initialized Yet"
|
64
|
+
return
|
65
|
+
end
|
66
|
+
@response = @@client.tobuffer(msg, opts)
|
67
|
+
'Saved'
|
68
|
+
end
|
69
|
+
|
70
|
+
def warn(msg, opts={})
|
71
|
+
opts[:level] = "WARN"
|
72
|
+
if @@client.nil?
|
73
|
+
puts "Logger Not Initialized Yet"
|
74
|
+
return
|
75
|
+
end
|
76
|
+
@response = @@client.tobuffer(msg, opts)
|
77
|
+
'Saved'
|
78
|
+
end
|
79
|
+
|
80
|
+
def error(msg, opts={})
|
81
|
+
opts[:level] = "ERROR"
|
82
|
+
if @@client.nil?
|
83
|
+
puts "Logger Not Initialized Yet"
|
84
|
+
return
|
85
|
+
end
|
86
|
+
@response = @@client.tobuffer(msg, opts)
|
87
|
+
'Saved'
|
88
|
+
end
|
89
|
+
|
90
|
+
def fatal(msg, opts={})
|
91
|
+
opts[:level] = "FATAL"
|
92
|
+
if @@client.nil?
|
20
93
|
puts "Logger Not Initialized Yet"
|
21
94
|
return
|
22
95
|
end
|
@@ -24,6 +97,8 @@ module Logdna
|
|
24
97
|
'Saved'
|
25
98
|
end
|
26
99
|
|
100
|
+
|
101
|
+
|
27
102
|
at_exit do
|
28
103
|
if defined? @@client
|
29
104
|
@@client.exitout()
|
data/lib/logdna/client.rb
CHANGED
@@ -54,6 +54,21 @@ module Logdna
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
def change(level, app, env)
|
58
|
+
if level
|
59
|
+
if level.is_a? Numeric
|
60
|
+
level = Resources::LOG_LEVELS[level]
|
61
|
+
end
|
62
|
+
@qs[:level] = level
|
63
|
+
end
|
64
|
+
if app
|
65
|
+
@qs[:app] = app
|
66
|
+
end
|
67
|
+
if env
|
68
|
+
@qs[:env] = env
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
57
72
|
def tobuffer(msg, opts)
|
58
73
|
if @task
|
59
74
|
unless @task.running?
|
data/lib/logdna/resources.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Resources
|
2
2
|
|
3
|
-
LOG_LEVELS = ['
|
3
|
+
LOG_LEVELS = ['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'].freeze
|
4
4
|
DEFAULT_REQUEST_HEADER = { 'Content-Type': 'application/json; charset=UTF-8' }.freeze
|
5
5
|
DEFAULT_REQUEST_TIMEOUT = 180000
|
6
6
|
MS_IN_A_DAY = 86400000
|
data/lib/logdna/version.rb
CHANGED
data/test.rb
CHANGED
@@ -1,34 +1,28 @@
|
|
1
1
|
require 'require_all'
|
2
2
|
require_all 'lib'
|
3
3
|
|
4
|
-
options = {
|
5
|
-
:level => "INFO", # LOG_LEVELS = ['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'] or your customized log level
|
6
|
-
:flushtime => 0.1,
|
7
|
-
:env => 'PRODUCTION'
|
8
|
-
}
|
9
4
|
|
10
|
-
|
11
|
-
:level => "INFO", # LOG_LEVELS = ['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'] or your customized log level
|
12
|
-
:flushtime => 0.1,
|
13
|
-
:env => 'STAGING'
|
14
|
-
}
|
5
|
+
options = {hostname: "yo", app: "globo-portal", env: "staging"}
|
15
6
|
|
16
|
-
options3 = {
|
17
|
-
:level => "INFO", # LOG_LEVELS = ['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'] or your customized log level
|
18
|
-
:flushtime => 0.1,
|
19
|
-
}
|
20
7
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
8
|
+
logger1 = Logdna::Ruby.new('deb5d62d893e82d6b03f3d4c20b96e15', options)
|
9
|
+
logger1.level = Logger::WARN
|
10
|
+
logger1.log('This should be warn')
|
11
|
+
logger1.trace('This should be trace')
|
12
|
+
logger1.log('Again warn level')
|
25
13
|
|
14
|
+
logger1.log('Warn level log1')
|
15
|
+
logger1.info('Info level log1')
|
16
|
+
logger1.level = Logger::DEBUG
|
17
|
+
logger1.log('DEBUG log1')
|
26
18
|
|
19
|
+
logger1.app = 'NEW APP NAME'
|
20
|
+
logger1.env = 'Staging'
|
21
|
+
logger1.level = 'INFO'
|
22
|
+
logger1.log('are changes all updated')
|
27
23
|
|
24
|
+
sleep 3
|
28
25
|
|
29
|
-
logger = Logdna::Ruby.new('Your Ingestion Key', options);
|
30
|
-
logger.log('YOYO');
|
31
|
-
logger.log('EQWEJQWIOE');
|
32
26
|
|
33
27
|
|
34
28
|
|
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.
|
4
|
+
version: 1.0.5
|
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-
|
11
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|