syslogger 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/syslogger.rb +5 -4
- data/spec/syslogger_spec.rb +12 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32d5b47d8aa6a4b2a3df0bf108b8ed76fea1540a
|
4
|
+
data.tar.gz: 314383df890e4fa2badaeb3a9b39f4f148f626be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5762ef3865af23f47acdeb71f4b8d197780a7a02b87604b53e561871fe9ac8815a794e41024b3f4ef57f8ff6e6c657166165a4b5ec021c855f6f26d574202585
|
7
|
+
data.tar.gz: ff39d2bf1863e1c391cb3c6b7f4625c9aa021838463df85be82d1801192f4ea6e18ab50c6f8912c055faebaf4c9dff036687628bb88709c895caec807ac3d579
|
data/lib/syslogger.rb
CHANGED
@@ -4,7 +4,7 @@ require 'thread'
|
|
4
4
|
|
5
5
|
class Syslogger
|
6
6
|
|
7
|
-
VERSION = "1.6.
|
7
|
+
VERSION = "1.6.2"
|
8
8
|
|
9
9
|
attr_reader :level, :ident, :options, :facility, :max_octets
|
10
10
|
attr_accessor :formatter
|
@@ -40,6 +40,7 @@ class Syslogger
|
|
40
40
|
# logger.level = Logger::INFO # use Logger levels
|
41
41
|
# logger.warn "warning message"
|
42
42
|
# logger.debug "debug message"
|
43
|
+
# logger.info "my_subapp" { "Some lazily computed message" }
|
43
44
|
#
|
44
45
|
def initialize(ident = $0, options = Syslog::LOG_PID | Syslog::LOG_CONS, facility = nil)
|
45
46
|
@ident = ident
|
@@ -56,9 +57,9 @@ class Syslogger
|
|
56
57
|
# Accepting *args as message could be nil.
|
57
58
|
# Default params not supported in ruby 1.8.7
|
58
59
|
define_method logger_method.to_sym do |*args, &block|
|
59
|
-
|
60
|
-
|
61
|
-
add(
|
60
|
+
severity = Logger.const_get(logger_method.upcase)
|
61
|
+
return true if @level > severity
|
62
|
+
add(severity, nil, args.first, &block)
|
62
63
|
end
|
63
64
|
|
64
65
|
unless logger_method == 'unknown'
|
data/spec/syslogger_spec.rb
CHANGED
@@ -31,6 +31,18 @@ describe "Syslogger" do
|
|
31
31
|
}.should_not raise_error
|
32
32
|
end
|
33
33
|
|
34
|
+
it "should log #{logger_method} using message as progname with the block's result" do
|
35
|
+
logger = Syslogger.new
|
36
|
+
logger.level = Logger.const_get(logger_method.upcase)
|
37
|
+
Syslog.should_receive(:open).with("Woah", anything, nil)
|
38
|
+
.and_yield(syslog=double("syslog", :mask= => true))
|
39
|
+
severity = Syslogger::MAPPING[Logger.const_get(logger_method.upcase)]
|
40
|
+
syslog.should_receive(:log).with(severity, "Some message that really needs a block")
|
41
|
+
lambda {
|
42
|
+
logger.send(logger_method.to_sym, "Woah") { "Some message that really needs a block" }
|
43
|
+
}.should_not raise_error
|
44
|
+
end
|
45
|
+
|
34
46
|
it "should log #{logger_method} without raising an exception if called with a nil message" do
|
35
47
|
logger = Syslogger.new
|
36
48
|
lambda {
|
@@ -54,7 +66,6 @@ describe "Syslogger" do
|
|
54
66
|
logger.send(logger_method.to_sym,msg)
|
55
67
|
}.should_not raise_error
|
56
68
|
end
|
57
|
-
|
58
69
|
end
|
59
70
|
|
60
71
|
%w{debug info warn error}.each do |logger_method|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syslogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Rohr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|