scrolls 0.9.4 → 0.9.6

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: 2c46a03de696acee9e14e71d9e2a373415e9fa60532a7ac51896f71b5e0286ca
4
- data.tar.gz: 9d9af16e271f1ff468fb778c8d5e05d9f215909adf77cdbf144204d2b3d8836e
3
+ metadata.gz: 0a22fdde95ee4d9fba497168f1e87870c4a2a9acb4dd9e3b3fbb2a0f57f403a2
4
+ data.tar.gz: 9bb1d566a68271d57fcfdbca02a0100fdb106a759ce5b4d9bd59cff35ed7431c
5
5
  SHA512:
6
- metadata.gz: 9aa2a50b5c00379872e54384b8f0b6050f82ab5f86e66bb2eca544a7ea5845ac4672dcc758e948d9b3af84b6d61af7972ca937be21854010002325c89b176865
7
- data.tar.gz: 992fc115e62d9a2ea39305a72db4bfd0868c0f64d2e1a47082136ecf01e2d7a16461bbfb69e5bb38da628a4e1331685c4f6da275277e9793dfe5c5a8a808c496
6
+ metadata.gz: e2d64db3b3d90206861fc46e5d9cf5d8744a3c94a48b304f0389fa17390a2e485eb3b6a1c9f655f5082491f3bc021fbd04a896c5d0b9ee18d970d0e1d8501972
7
+ data.tar.gz: 0ae6039a25a4525f30717e0a1f3b8b295912c18fff09b41294a558e8a3b035ee8b5feb7ac74d8d5f8c78d920105ad42af818f4f07c1b714032f771b7aed92cc6
data/lib/scrolls/utils.rb CHANGED
@@ -53,9 +53,9 @@ module Scrolls
53
53
 
54
54
  def self.escape_chars(d)
55
55
  if d.is_a?(String) and d =~ ESCAPE_CHAR_PATTERN
56
- esc = d.to_s.gsub(ESCAPE_CHAR_PATTERN) {|c| ESCAPE_CHAR[c] }
56
+ d.to_s.gsub(ESCAPE_CHAR_PATTERN) {|c| ESCAPE_CHAR[c] }
57
57
  else
58
- esc = d
58
+ d
59
59
  end
60
60
  end
61
61
 
@@ -1,3 +1,3 @@
1
1
  module Scrolls
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.6"
3
3
  end
data/lib/scrolls.rb CHANGED
@@ -7,19 +7,21 @@ module Scrolls
7
7
  # Public: Initialize a Scrolls logger
8
8
  #
9
9
  # options - A hash of key/values for configuring Scrolls
10
- # stream - Stream to output data (default: STDOUT)
11
- # log_facility - Syslog facility (default: Syslog::LOG_USER)
12
- # time_unit - Unit of time (default: seconds)
13
- # timestamp - Prepend logs with a timestamp (default: false)
14
- # exceptions - Method for outputting exceptions (default: single line)
15
- # global_context - Immutable context to prepend all messages with
16
- # syslog_options - Syslog options (default: Syslog::LOG_PID|Syslog::LOG_CONS)
17
- # escape_keys - Escape chars in keys
18
- # strict_logfmt - Always use double quotes to quote values
10
+ # stream - Stream to output data (default: STDOUT)
11
+ # log_facility - Syslog facility (default: Syslog::LOG_USER)
12
+ # time_unit - Unit of time (default: seconds)
13
+ # timestamp - Prepend logs with a timestamp (default: false)
14
+ # exceptions - Method for outputting exceptions (default: single line)
15
+ # global_context - Immutable context to prepend all messages with
16
+ # syslog_options - Syslog options (default: Syslog::LOG_PID|Syslog::LOG_CONS)
17
+ # escape_keys - Escape chars in keys
18
+ # strict_logfmt - Always use double quotes to quote values
19
+ # adapt_severity_for_syslog - Downgrade severity one level to match syslog (default: true) per https://docs.ruby-lang.org/en/2.1.0/Syslog/Logger.html
19
20
  #
20
21
  def init(options={})
21
22
  # Set a hint whether #init was called.
22
23
  @initialized = true
24
+ @adapt_severity_for_syslog = options.fetch(:adapt_severity_for_syslog, true)
23
25
  @log = Logger.new(options)
24
26
  end
25
27
 
@@ -242,7 +244,7 @@ module Scrolls
242
244
  #
243
245
  def error(data, &blk)
244
246
  data = coalesce_strings_to_hash(data)
245
- data = data.merge(:level => "warning") if data.is_a?(Hash)
247
+ data = data.merge(:level => @adapt_severity_for_syslog ? "warning" : "error") if data.is_a?(Hash)
246
248
  @log.log(data, &blk)
247
249
  end
248
250
 
@@ -261,7 +263,7 @@ module Scrolls
261
263
  #
262
264
  def fatal(data, &blk)
263
265
  data = coalesce_strings_to_hash(data)
264
- data = data.merge(:level => "error") if data.is_a?(Hash)
266
+ data = data.merge(:level => @adapt_severity_for_syslog ? "error" : "critical") if data.is_a?(Hash)
265
267
  @log.log(data, &blk)
266
268
  end
267
269
 
@@ -299,7 +301,7 @@ module Scrolls
299
301
  #
300
302
  def warn(data, &blk)
301
303
  data = coalesce_strings_to_hash(data)
302
- data = data.merge(:level => "notice") if data.is_a?(Hash)
304
+ data = data.merge(:level => @adapt_severity_for_syslog ? "notice" : "warn") if data.is_a?(Hash)
303
305
  @log.log(data, &blk)
304
306
  end
305
307
 
data/scrolls.gemspec CHANGED
@@ -14,4 +14,6 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "scrolls"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Scrolls::VERSION
17
+
18
+ gem.add_dependency "syslog"
17
19
  end
data/test/test_scrolls.rb CHANGED
@@ -236,6 +236,24 @@ class TestScrolls < Minitest::Test
236
236
  assert_equal "log_message=warn level=notice\n", @out.string
237
237
  end
238
238
 
239
+ def test_adapted_log_error
240
+ Scrolls.init({:stream => @out, :adapt_severity_for_syslog => false })
241
+ Scrolls.error("error")
242
+ assert_equal "log_message=error level=error\n", @out.string
243
+ end
244
+
245
+ def test_adapted_log_fatal
246
+ Scrolls.init({:stream => @out, :adapt_severity_for_syslog => false })
247
+ Scrolls.fatal("fatal")
248
+ assert_equal "log_message=fatal level=critical\n", @out.string
249
+ end
250
+
251
+ def test_adapted_log_warn
252
+ Scrolls.init({:stream => @out, :adapt_severity_for_syslog => false })
253
+ Scrolls.warn("warn")
254
+ assert_equal "log_message=warn level=warn\n", @out.string
255
+ end
256
+
239
257
  def test_sending_string_unknown
240
258
  Scrolls.unknown("unknown")
241
259
  assert_equal "log_message=unknown level=alert\n", @out.string
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrolls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Curt Micol
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-22 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: syslog
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Logging, easier, more consistent.
14
28
  email:
15
29
  - asenchi@asenchi.com
@@ -39,7 +53,7 @@ homepage: https://github.com/asenchi/scrolls
39
53
  licenses:
40
54
  - MIT
41
55
  metadata: {}
42
- post_install_message:
56
+ post_install_message:
43
57
  rdoc_options: []
44
58
  require_paths:
45
59
  - lib
@@ -54,8 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
68
  - !ruby/object:Gem::Version
55
69
  version: '0'
56
70
  requirements: []
57
- rubygems_version: 3.2.29
58
- signing_key:
71
+ rubygems_version: 3.5.11
72
+ signing_key:
59
73
  specification_version: 4
60
74
  summary: When do we log? All the time.
61
75
  test_files: