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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61d4c08ece5a3e956448ef53ca8bfa1a0e4e3b5e9280eb39e705858b9939b708
4
- data.tar.gz: 3c481e062a5ab699d8c72ba9625f7528f41b94f075177df284f238d9117cacce
3
+ metadata.gz: f126120755d87024c112a4e93b50f2594ae2e1243a42bb5b919e1c774ac3b1b6
4
+ data.tar.gz: b12087121bd87040c4725d0314fa730f968da85d003e71510f334da2a9b13e91
5
5
  SHA512:
6
- metadata.gz: cc079a6ced8d0cbec9a23b552056d06a4ebc139a5afb54cbc4eadb7c416ca390263e3c3c29c47009e53954db8176305a398fb8ceaddb3696a676bf6d414f0a45
7
- data.tar.gz: 6ed71d2a2b742a0634cb3fca8c92e1e0b9a835bbf55f9ada5a9144f40184d01338065ce587d98035e6409a31424ef2a01818e566f5a1cb56e618962f7ac360df
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 = Formatter.new
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
@@ -14,6 +14,7 @@ module Startback
14
14
 
15
15
  end # module Support
16
16
  end # module Startback
17
+ require_relative 'support/log_formatter'
17
18
  require_relative 'support/logger'
18
19
  require_relative 'support/robustness'
19
20
  require_relative 'support/hooks'
@@ -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 ||= ::Logger.new(STDOUT)
44
- from = caller.reject{|x| x =~ /lib\/startback/ }.first
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
@@ -2,7 +2,7 @@ module Startback
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- TINY = 1
5
+ TINY = 2
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -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.1
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-19 00:00:00.000000000 Z
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