startback 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/startback/audit/trailer.rb +1 -16
- data/lib/startback/caching/entity_cache.rb +3 -3
- data/lib/startback/support.rb +1 -0
- data/lib/startback/support/log_formatter.rb +18 -0
- data/lib/startback/support/robustness.rb +7 -3
- data/lib/startback/version.rb +1 -1
- data/lib/startback/web/catch_all.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f126120755d87024c112a4e93b50f2594ae2e1243a42bb5b919e1c774ac3b1b6
|
4
|
+
data.tar.gz: b12087121bd87040c4725d0314fa730f968da85d003e71510f334da2a9b13e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a08330ffbdb7a1901608d885e478d98e4f56313193d1d3af35e162ddcf3153df76c5f5cd596a49810f0303542f31c03efe450a700e64661a46951d9011800a5
|
7
|
+
data.tar.gz: 7ce42ae03edbc5570965d0b3727bc46c5a2ae08cfb886fe785a5ce3e092711678f7d77ea54317daeb0a4e84af278177d11920cc860ab180f8176cdfb73abcb92
|
@@ -48,21 +48,6 @@ module Startback
|
|
48
48
|
extend Forwardable
|
49
49
|
def_delegators :@logger, :debug, :info, :warn, :error, :fatal
|
50
50
|
|
51
|
-
class Formatter
|
52
|
-
|
53
|
-
def call(severity, time, progname, msg)
|
54
|
-
if msg[:error] && msg[:error].respond_to?(:message, true)
|
55
|
-
msg[:backtrace] = msg[:error].backtrace[0..25] if severity == "FATAL"
|
56
|
-
msg[:error] = msg[:error].message
|
57
|
-
end
|
58
|
-
{
|
59
|
-
severity: severity,
|
60
|
-
time: time,
|
61
|
-
}.merge(msg).to_json << "\n"
|
62
|
-
end
|
63
|
-
|
64
|
-
end # class Formatter
|
65
|
-
|
66
51
|
DEFAULT_OPTIONS = {
|
67
52
|
|
68
53
|
# Words used to stop dumping for, e.g., security reasons
|
@@ -73,7 +58,7 @@ module Startback
|
|
73
58
|
def initialize(device, options = {})
|
74
59
|
@options = DEFAULT_OPTIONS.merge(options)
|
75
60
|
@logger = ::Logger.new(device, 'daily')
|
76
|
-
@logger.formatter =
|
61
|
+
@logger.formatter = Support::LogFormatter.new
|
77
62
|
end
|
78
63
|
attr_reader :logger, :options
|
79
64
|
|
@@ -78,15 +78,15 @@ module Startback
|
|
78
78
|
protected
|
79
79
|
|
80
80
|
def cache_hit(pkey, cached)
|
81
|
-
log(:debug, self, "cache_hit", op_data: pkey)
|
81
|
+
log(:debug, self, "cache_hit", context, op_data: pkey)
|
82
82
|
end
|
83
83
|
|
84
84
|
def cache_outdated(pkey, cached)
|
85
|
-
log(:info, self, "cache_outdated", op_data: pkey)
|
85
|
+
log(:info, self, "cache_outdated", context, op_data: pkey)
|
86
86
|
end
|
87
87
|
|
88
88
|
def cache_miss(pkey)
|
89
|
-
log(:info, self, "cache_miss", op_data: pkey)
|
89
|
+
log(:info, self, "cache_miss", context, op_data: pkey)
|
90
90
|
end
|
91
91
|
|
92
92
|
def default_caching_options
|
data/lib/startback/support.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Startback
|
2
|
+
module Support
|
3
|
+
class LogFormatter
|
4
|
+
|
5
|
+
def call(severity, time, progname, msg)
|
6
|
+
if msg[:error] && msg[:error].respond_to?(:message, true)
|
7
|
+
msg[:backtrace] = msg[:error].backtrace[0..25] if severity == "FATAL"
|
8
|
+
msg[:error] = msg[:error].message
|
9
|
+
end
|
10
|
+
{
|
11
|
+
severity: severity,
|
12
|
+
time: time,
|
13
|
+
}.merge(msg).to_json << "\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
end # class LogFormatter
|
17
|
+
end # module Support
|
18
|
+
end # module Startback
|
@@ -40,8 +40,12 @@ module Startback
|
|
40
40
|
module Tools
|
41
41
|
|
42
42
|
def default_logger
|
43
|
-
@@default_logger ||=
|
44
|
-
|
43
|
+
@@default_logger ||= begin
|
44
|
+
l = ::Logger.new(STDOUT)
|
45
|
+
l.formatter = LogFormatter.new
|
46
|
+
l.warn(op: "#{self}", op_data: { msg: "Using default logger", trace: caller })
|
47
|
+
@@default_logger = l
|
48
|
+
end
|
45
49
|
@@default_logger
|
46
50
|
end
|
47
51
|
module_function :default_logger
|
@@ -74,7 +78,7 @@ module Startback
|
|
74
78
|
|
75
79
|
[:debug, :info, :warn, :error, :fatal].each do |meth|
|
76
80
|
define_method(meth) do |args, extra = nil, &bl|
|
77
|
-
act_args = args + [extra]
|
81
|
+
act_args = (args + [extra]).compact
|
78
82
|
log_msg, logger = parse_args(*act_args)
|
79
83
|
logger.send(meth, log_msg)
|
80
84
|
end
|
data/lib/startback/version.rb
CHANGED
@@ -38,7 +38,7 @@ module Startback
|
|
38
38
|
if context && context.respond_to?(:error_handler, true) && context.error_handler
|
39
39
|
context.error_handler.fatal(ex)
|
40
40
|
else
|
41
|
-
log(:fatal, self, "ensure", error: ex)
|
41
|
+
log(:fatal, self, "ensure", context, error: ex)
|
42
42
|
end
|
43
43
|
rescue => ex2
|
44
44
|
STDERR.puts(ex2.message)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: startback
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- lib/startback/support.rb
|
170
170
|
- lib/startback/support/fake_logger.rb
|
171
171
|
- lib/startback/support/hooks.rb
|
172
|
+
- lib/startback/support/log_formatter.rb
|
172
173
|
- lib/startback/support/logger.rb
|
173
174
|
- lib/startback/support/operation_runner.rb
|
174
175
|
- lib/startback/support/robustness.rb
|