cabin 0.8.2 → 0.9.0
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 +5 -5
- data/lib/cabin/channel.rb +2 -1
- data/lib/cabin/mixins/logger.rb +4 -4
- data/test/cabin/test_logging.rb +0 -3
- data/test/test_helper.rb +3 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1d6cedfb168cb19e83ec4be1bb2f22f344169e9b
|
4
|
+
data.tar.gz: 8dbc9febd137b05ad067e49ae05c0334d0e8d265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d8dd5d0af37d7e45ee89b66f28bad3f09ceac163a02c2ebc0fb9f4c9901fce926e3740be772c8636cc42fb7f3984921315d5e417d8c27ae3e649aed772e5572
|
7
|
+
data.tar.gz: a13ada6bc3a54a77da625ace14e5c2766c7e09a641dea8a03023664af9874c9355b43b6ac89c26c1d071cdd4175160d7c359ab7965552cb2c5ae1e651b62ba9f
|
data/lib/cabin/channel.rb
CHANGED
@@ -9,6 +9,7 @@ require "cabin/outputs/stdlib-logger"
|
|
9
9
|
require "cabin/outputs/io"
|
10
10
|
require "cabin/subscriber"
|
11
11
|
require "cabin/metrics"
|
12
|
+
require "logger" # stdlib
|
12
13
|
require "thread"
|
13
14
|
|
14
15
|
# A wonderful channel for logging.
|
@@ -134,7 +135,7 @@ class Cabin::Channel
|
|
134
135
|
# Returns a subscription id you can use later to unsubscribe
|
135
136
|
def subscribe(output, options = {})
|
136
137
|
# Wrap ruby stdlib Logger if given.
|
137
|
-
if
|
138
|
+
if output.is_a?(::Logger)
|
138
139
|
output = Cabin::Outputs::StdlibLogger.new(output)
|
139
140
|
elsif output.is_a?(::IO)
|
140
141
|
output = Cabin::Outputs::IO.new(output)
|
data/lib/cabin/mixins/logger.rb
CHANGED
@@ -20,8 +20,7 @@ module Cabin::Mixins::Logger
|
|
20
20
|
:error => 1,
|
21
21
|
:warn => 2,
|
22
22
|
:info => 3,
|
23
|
-
:debug => 4
|
24
|
-
:trace => 5
|
23
|
+
:debug => 4
|
25
24
|
}
|
26
25
|
|
27
26
|
BACKTRACE_RE = /([^:]+):([0-9]+)(?::in `(.*)')?/
|
@@ -38,14 +37,15 @@ module Cabin::Mixins::Logger
|
|
38
37
|
# Each level-based method accepts both a message and a hash data.
|
39
38
|
#
|
40
39
|
# This will define methods such as 'fatal' and 'fatal?' for each
|
41
|
-
# of: fatal, error, warn, info, debug
|
40
|
+
# of: fatal, error, warn, info, debug
|
42
41
|
#
|
43
42
|
# The first method type (ie Cabin::Channel#fatal) is what logs, and it takes a
|
44
43
|
# message and an optional Hash with context.
|
45
44
|
#
|
46
45
|
# The second method type (ie; Cabin::Channel#fatal?) returns true if
|
47
46
|
# fatal logs are being emitted, false otherwise.
|
48
|
-
|
47
|
+
%w(fatal error warn info debug).each do |level|
|
48
|
+
level = level.to_sym
|
49
49
|
predicate = "#{level}?".to_sym
|
50
50
|
|
51
51
|
# def info, def warn, etc...
|
data/test/cabin/test_logging.rb
CHANGED
@@ -67,7 +67,6 @@ describe Cabin::Channel do
|
|
67
67
|
sub2 = Receiver.new
|
68
68
|
@logger.subscribe(sub1, :level => :info)
|
69
69
|
@logger.subscribe(sub2, :level => :error)
|
70
|
-
@logger.trace("test trace")
|
71
70
|
@logger.debug("test debug")
|
72
71
|
@logger.info("test info")
|
73
72
|
@logger.error("test error")
|
@@ -76,7 +75,6 @@ describe Cabin::Channel do
|
|
76
75
|
assert_equal("test error", sub1.data[1][:message])
|
77
76
|
assert_equal("test error", sub2.data[0][:message])
|
78
77
|
end
|
79
|
-
|
80
78
|
test "context values" do
|
81
79
|
context = @logger.context
|
82
80
|
context["foo"] = "hello"
|
@@ -176,5 +174,4 @@ describe Cabin::Channel do
|
|
176
174
|
assert_equal("Hello world", event[:message])
|
177
175
|
assert_equal(:info, event[:level])
|
178
176
|
end
|
179
|
-
|
180
177
|
end # describe Cabin::Channel do
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cabin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Sissel
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date:
|
11
|
+
date: 2016-08-30 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: rake
|
@@ -79,6 +80,7 @@ homepage: https://github.com/jordansissel/ruby-cabin
|
|
79
80
|
licenses:
|
80
81
|
- Apache License (2.0)
|
81
82
|
metadata: {}
|
83
|
+
post_install_message:
|
82
84
|
rdoc_options: []
|
83
85
|
require_paths:
|
84
86
|
- lib
|
@@ -94,7 +96,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
96
|
- !ruby/object:Gem::Version
|
95
97
|
version: '0'
|
96
98
|
requirements: []
|
97
|
-
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.4.8
|
101
|
+
signing_key:
|
98
102
|
specification_version: 4
|
99
103
|
summary: Experiments in structured and contextual logging
|
100
104
|
test_files: []
|
105
|
+
has_rdoc:
|