ree_lib 1.0.26 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dd3e34cf8cf522890742c6b5755c536839b2115e079d9a28b03eeb301b3c2fc
4
- data.tar.gz: 32f9bc239d26c1ae3727e972efe56e76fc90f5123bceeecac4c7ab3cc5e5daac
3
+ metadata.gz: 1dee10604487127cc63af20d01924626af8cdd4e5559a1b8716d2065f2ef0c95
4
+ data.tar.gz: 742e3d4ec4990eb9989cf904e7fb3eb5ed4eb6d06e5c3791a3188f1ec22cc7b5
5
5
  SHA512:
6
- metadata.gz: 16ebde5de8ade23d0c8bd5bbf94792002e4c5f64bb4c14bed11eb5c04c87e1349bac70fe98ea3c19ae7b765690d87de5fb259f6350d74ece11bc177ee4ab6699
7
- data.tar.gz: e3ec1e71678e1604d40ef1c07e92af04acfa335b967f86b0a248356c7641270f0ec72d42c874cf176b6bc1fa7a04af534bdf3ecdcf1ef74e0f96362b4a933fe7
6
+ metadata.gz: 54aa51badb91b3b3dba8ff6429d3f219bb17e099fb22b0202b6a8a72a65ab0425c56d5237df5fb7a27b8622db2a3f7b453162a6a7d2fc4681acb5c4bda2f840b
7
+ data.tar.gz: 75729a0e3b80a7e57e18ba4a3c45a41a96d31dab16868e168e4a31e564166f32b2783ee16c0f4e27412c4edb56d01795875ca5e4d153159d68d71fa961aa3c2e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.26)
4
+ ree_lib (1.0.28)
5
5
  binding_of_caller (~> 1.0.0)
6
6
  i18n (~> 1.12.0)
7
7
  loofah (~> 2.18.0)
@@ -46,7 +46,7 @@ GEM
46
46
  racc (1.6.2)
47
47
  rainbow (3.1.1)
48
48
  rake (13.0.6)
49
- ree (1.0.13)
49
+ ree (1.0.14)
50
50
  commander (~> 4.6.0)
51
51
  rexml (3.2.5)
52
52
  rollbar (3.3.3)
@@ -34,7 +34,7 @@ class ReeLogger::FileAppender < ReeLogger::Appender
34
34
 
35
35
  opts = DEFAULTS.merge(opts)
36
36
 
37
- unless File.exists?(file_path)
37
+ unless File.exist?(file_path)
38
38
  FileUtils.mkdir_p(Pathname.new(file_path).parent.to_s)
39
39
  FileUtils.touch(file_path)
40
40
  end
@@ -1,10 +1,10 @@
1
1
  class ReeLogger::MultiLogger < Logger
2
2
  include Ree::LinkDSL
3
3
 
4
- link 'ree_logger/rate_limiter', -> { RateLimiter }
5
- link 'ree_logger/log_event', -> { LogEvent }
6
- link :transform_values, from: :ree_hash
7
4
  link :as_json, from: :ree_object
5
+ link :transform_values, from: :ree_hash
6
+ link 'ree_logger/log_event', -> { LogEvent }
7
+ link 'ree_logger/rate_limiter', -> { RateLimiter }
8
8
 
9
9
  undef level=
10
10
  undef datetime_format
@@ -26,7 +26,7 @@ class ReeLogger::MultiLogger < Logger
26
26
  Nilor[String],
27
27
  Nilor[RateLimiter],
28
28
  Nilor[ArrayOf[String]] => Any
29
- )
29
+ ).throws(ArgumentError)
30
30
  def initialize(progname, rate_limiter, filter_words)
31
31
  @progname = progname
32
32
  @rate_limiter = rate_limiter
@@ -57,34 +57,64 @@ class ReeLogger::MultiLogger < Logger
57
57
  @silenced = false
58
58
  end
59
59
 
60
- contract(String, Hash, Nilor[Exception], Bool => nil)
61
- def debug(message, parameters = {}, exception = nil, log_args = false)
62
- log(:debug, message, parameters, nil, false)
60
+ contract(Nilor[String], Hash, Nilor[Exception], Bool, Nilor[String], Optblock => nil)
61
+ def debug(message = nil, parameters = {}, exception = nil, log_args = false, progname = nil, &block)
62
+ if block_given?
63
+ log(:debug, yield, parameters, nil, log_args)
64
+ else
65
+ msg = get_message(message)
66
+ log(:debug, msg, parameters, nil, log_args)
67
+ end
63
68
  end
64
69
 
65
- contract(String, Hash, Nilor[Exception], Bool => nil)
66
- def info(message, parameters = {}, exception = nil, log_args = false)
67
- log(:info, message, parameters, nil)
70
+ contract(Nilor[String], Hash, Nilor[Exception], Bool, Nilor[String], Optblock => nil)
71
+ def info(message = nil, parameters = {}, exception = nil, log_args = false, progname = nil, &block)
72
+ if block_given?
73
+ log(:info, yield, parameters, nil, log_args)
74
+ else
75
+ msg = get_message(message)
76
+ log(:info, msg, parameters, nil)
77
+ end
68
78
  end
69
79
 
70
- contract(String, Hash, Nilor[Exception], Bool => nil)
71
- def warn(message, parameters = {}, exception = nil, log_args = false)
72
- log(:warn, message, parameters, nil)
80
+ contract(Nilor[String], Hash, Nilor[Exception], Bool, Nilor[String], Optblock => nil)
81
+ def warn(message = nil, parameters = {}, exception = nil, log_args = false, progname = nil, &block)
82
+ if block_given?
83
+ log(:warn, yield, parameters, nil, log_args)
84
+ else
85
+ msg = get_message(message)
86
+ log(:warn, msg, parameters, nil)
87
+ end
73
88
  end
74
89
 
75
- contract(String, Hash, Nilor[Exception], Bool => nil)
76
- def error(message, parameters = {}, exception = nil, log_args = true)
77
- log(:error, message, parameters, exception, log_args)
90
+ contract(Nilor[String], Hash, Nilor[Exception], Bool, Nilor[String], Optblock => nil)
91
+ def error(message = nil, parameters = {}, exception = nil, log_args = true, progname = nil, &block)
92
+ if block_given?
93
+ log(:error, yield, parameters, exception, log_args)
94
+ else
95
+ msg = get_message(message)
96
+ log(:error, msg, parameters, exception, log_args)
97
+ end
78
98
  end
79
99
 
80
- contract(String, Hash, Nilor[Exception], Bool => nil)
81
- def fatal(message, parameters = {}, exception = nil, log_args = true)
82
- log(:error, message, parameters, exception, true)
100
+ contract(Nilor[String], Hash, Nilor[Exception], Bool, Nilor[String], Optblock => nil)
101
+ def fatal(message = nil, parameters = {}, exception = nil, log_args = true, progname = nil, &block)
102
+ if block_given?
103
+ log(:error, yield, parameters, exception, log_args)
104
+ else
105
+ msg = get_message(message)
106
+ log(:error, msg, parameters, exception, log_args)
107
+ end
83
108
  end
84
109
 
85
- contract(String, Hash, Nilor[Exception], Bool => nil)
86
- def unknown(message, parameters = {}, exception = nil, log_args = true)
87
- log(:unknown, message, parameters, exception, true)
110
+ contract(Nilor[String], Hash, Nilor[Exception], Bool, Nilor[String], Optblock => nil)
111
+ def unknown(message = nil, parameters = {}, exception = nil, log_args = true, progname = nil, &block)
112
+ if block_given?
113
+ log(:unknown, yield, parameters, exception, log_args)
114
+ else
115
+ msg = get_message(message)
116
+ log(:unknown, msg, parameters, exception, log_args)
117
+ end
88
118
  end
89
119
 
90
120
  contract(Symbol, String, Hash, Nilor[Exception], Bool => nil)
@@ -158,4 +188,8 @@ class ReeLogger::MultiLogger < Logger
158
188
  def higher_or_equal_level?(message_level, appender_level)
159
189
  LEVEL_MAPPING[message_level] >= LEVEL_MAPPING[appender_level]
160
190
  end
191
+
192
+ def get_message(message)
193
+ message || (raise ArgumentError.new("message should be given"))
194
+ end
161
195
  end
@@ -81,6 +81,12 @@ RSpec.describe ReeLogger::MultiLogger do
81
81
  expect(File.read(log_file_path)).to match("hello world")
82
82
  }
83
83
 
84
+ it {
85
+ expect { logger_with_appenders.info {'block message'} }.to output(/block message/).to_stdout
86
+ expect(Rollbar).to have_received(:log)
87
+ expect(File.read(log_file_path)).to match("block message")
88
+ }
89
+
84
90
  it {
85
91
  expect { logger_with_appenders.info('hello world', { param: 1, another_param: { name: 'John'}, password: 'password01' }) }.to output(/John/).to_stdout
86
92
  expect(Rollbar).to have_received(:log)
@@ -136,6 +142,4 @@ RSpec.describe ReeLogger::MultiLogger do
136
142
  end
137
143
  }.to_not output.to_stdout
138
144
  }
139
-
140
-
141
145
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.26"
4
+ VERSION = "1.0.28"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ree_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.26
4
+ version: 1.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-08 00:00:00.000000000 Z
11
+ date: 2023-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ree