releaseable 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/releaseable/extensions.rb +40 -17
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.9
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'logger'
|
2
2
|
require 'logglier'
|
3
|
+
require 'stringio'
|
3
4
|
require 'java'
|
4
5
|
|
5
6
|
# Selectively silence verbose JRuby warnings
|
6
|
-
def
|
7
|
+
def suppress_warnings
|
7
8
|
old_verbose = $VERBOSE
|
8
9
|
begin
|
9
10
|
$VERBOSE = nil
|
@@ -15,7 +16,7 @@ def suppress_all_warnings
|
|
15
16
|
end
|
16
17
|
|
17
18
|
# Avoid OpenSSL failures
|
18
|
-
|
19
|
+
suppress_warnings do
|
19
20
|
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
20
21
|
end
|
21
22
|
|
@@ -27,7 +28,7 @@ class Logger
|
|
27
28
|
:json => '62a8ef41-fd80-460f-a6f7-e45f232dd1d8',
|
28
29
|
:aux => '207f124e-9de6-434f-b100-af1ac3585089', }
|
29
30
|
|
30
|
-
attr_accessor :config
|
31
|
+
attr_accessor :config, :logdev
|
31
32
|
|
32
33
|
# Alarm sound to get my attention
|
33
34
|
def self.sound_alarm beeps = 3
|
@@ -42,21 +43,39 @@ class Logger
|
|
42
43
|
self.class.sound_alarm beeps
|
43
44
|
end
|
44
45
|
|
46
|
+
# Trace errors in json format
|
47
|
+
def trace error
|
48
|
+
if @fatalities
|
49
|
+
hash = error.is_a?(Hash) ? error : {:msg => error}
|
50
|
+
@fatalities.add(hash[:severity] || Logger::UNKNOWN) do
|
51
|
+
hash.merge :tag => @config[:tag]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Finalize logger
|
57
|
+
def finalize
|
58
|
+
if @fatalities
|
59
|
+
trace :failsafe => @config[:failsafe].string if @config[:failsafe].respond_to? :string
|
60
|
+
sleep 1
|
61
|
+
@fatalities.logdev.dev.deliverer.kill
|
62
|
+
end
|
63
|
+
close
|
64
|
+
end
|
65
|
+
|
45
66
|
alias old_fatal fatal
|
46
67
|
|
47
|
-
# Extended handler for fatal errors
|
48
68
|
def fatal *args
|
49
|
-
if @
|
69
|
+
if @fatalities
|
50
70
|
entry = args.first
|
51
71
|
case entry
|
52
72
|
when Exception
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
73
|
+
trace :severity => Logger::FATAL,
|
74
|
+
:error => entry.class,
|
75
|
+
:msg => entry.message,
|
76
|
+
:backtrace => (entry.backtrace || []).join(', ')
|
57
77
|
else
|
58
|
-
|
59
|
-
:msg => "#{args.join(', ')}"
|
78
|
+
trace :severity => Logger::INFO, :msg => "#{args.join(', ')}"
|
60
79
|
old_fatal *args
|
61
80
|
end
|
62
81
|
else
|
@@ -64,7 +83,7 @@ class Logger
|
|
64
83
|
end
|
65
84
|
end
|
66
85
|
|
67
|
-
|
86
|
+
# Extended configuration for Logger
|
68
87
|
def configure config={}, &formatter
|
69
88
|
@config = (config[:log] || config).dup
|
70
89
|
@config[:beeps] ||= 0
|
@@ -82,11 +101,14 @@ class Logger
|
|
82
101
|
@config[:input]
|
83
102
|
end
|
84
103
|
domain ||= @config[:domain] || 'https://logs.loggly.com'
|
85
|
-
@config[:
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
104
|
+
@config[:failsafe] ||= StringIO.new("") # $stderr
|
105
|
+
|
106
|
+
@fatalities ||= Logglier.new "#{domain}/inputs/#{input}",
|
107
|
+
:failsafe => @config[:failsafe],
|
108
|
+
:read_timeout => 10, # defaults to 120
|
109
|
+
:open_timeout => 10, # defaults to 120
|
110
|
+
:threaded => true,
|
111
|
+
:format => :json
|
90
112
|
end
|
91
113
|
|
92
114
|
self.level = @config[:level] || Logger::INFO
|
@@ -94,4 +116,5 @@ class Logger
|
|
94
116
|
"#{time.strftime(@config[:time_format])} #{msg}\n"
|
95
117
|
end
|
96
118
|
end
|
119
|
+
|
97
120
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: releaseable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.9
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- arvicco
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-01-
|
13
|
+
date: 2012-01-30 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|