scrolls 0.9.4 → 0.9.5

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: c9e31caada359ce18dceed5246a8da245c3a8587f02ebe079e3317baf2f50551
4
+ data.tar.gz: 28cfb3b4ed27598042d5499d9b3e5105bab48562b3d18dd6c678398cbcee6d0b
5
5
  SHA512:
6
- metadata.gz: 9aa2a50b5c00379872e54384b8f0b6050f82ab5f86e66bb2eca544a7ea5845ac4672dcc758e948d9b3af84b6d61af7972ca937be21854010002325c89b176865
7
- data.tar.gz: 992fc115e62d9a2ea39305a72db4bfd0868c0f64d2e1a47082136ecf01e2d7a16461bbfb69e5bb38da628a4e1331685c4f6da275277e9793dfe5c5a8a808c496
6
+ metadata.gz: c9fadc0c6475e40c4d427295f1d9b9db218e1038bcca634ebd00da18a80aced226510e6ea69a1c66c817cae947cff7cff621a7532cbeb6428c7e3bbaf9049913
7
+ data.tar.gz: 99293d2de9ac23a5d07e3551a88964f3f76ca5537002915480ba898acc8ba0171355da7930e27d3d085a5eb34e75e865237bc192c6bf4396884366c7230b344b
@@ -1,3 +1,3 @@
1
1
  module Scrolls
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.5"
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/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,14 +1,14 @@
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Curt Micol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-22 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Logging, easier, more consistent.
14
14
  email: