logmaster 0.1.4 → 0.1.5
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 +4 -4
- data/VERSION +1 -1
- data/lib/logmaster.rb +3 -3
- data/logmaster.gemspec +2 -2
- data/spec/logmaster_spec.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ce272e5aa3a718e5b0bb7663788571ea9a10182
|
4
|
+
data.tar.gz: 069f320d9876dac93e4bdbc5d11b62d23e4c03e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 919757dd7c26ef431e9a8fb8ea4aebe4d9b593adf634f2cb0daab9552c54e655693c7a0670b980a3fe6fe2dadd4c5cacb41ffeff07c27484127113b707b5b30b
|
7
|
+
data.tar.gz: a1e720193bc2c5277bead5140598c699e2a2bcd5abb2404cf5e29728ba9430fe634e3837caf39bc787fefb109059505261b9f6d1aa381f5610d51f141b55a408
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/lib/logmaster.rb
CHANGED
@@ -2,7 +2,7 @@ require 'logger'
|
|
2
2
|
|
3
3
|
class Logmaster
|
4
4
|
|
5
|
-
attr_accessor :loggers, :log_level, :name, :email_config, :raise_exception
|
5
|
+
attr_accessor :loggers, :log_level, :name, :email_config, :raise_exception, :email_log_level
|
6
6
|
|
7
7
|
def initialize(
|
8
8
|
log_level: Logger::INFO,
|
@@ -43,7 +43,7 @@ class Logmaster
|
|
43
43
|
|
44
44
|
# Because pony doesn't like some arbitrary options like log_level
|
45
45
|
# and instead of ignorning them, throws an error.
|
46
|
-
@email_log_level = @email_config[:log_level]
|
46
|
+
@email_log_level = Logger.const_get(@email_config[:log_level].to_s.upcase)
|
47
47
|
@email_config.delete(:log_level)
|
48
48
|
|
49
49
|
end
|
@@ -70,7 +70,7 @@ class Logmaster
|
|
70
70
|
|
71
71
|
if [:unknown, :fatal, :error, :warn, :info, :debug].include?(name)
|
72
72
|
|
73
|
-
if @email_config && @
|
73
|
+
if @email_config && @email_log_level <= Logger.const_get(name.to_s.upcase)
|
74
74
|
send_email(type: name, message: args[0])
|
75
75
|
end
|
76
76
|
|
data/logmaster.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: logmaster 0.1.
|
5
|
+
# stub: logmaster 0.1.5 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "logmaster"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.5"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
data/spec/logmaster_spec.rb
CHANGED
@@ -26,7 +26,8 @@ describe Logmaster do
|
|
26
26
|
|
27
27
|
it "sets email settings" do
|
28
28
|
@logmaster.email_config = { to: 'your-email@here.com' }
|
29
|
-
expect(@logmaster.email_config).to eq({ via: :sendmail, from: 'logmaster@localhost', subject: "Logmaster message", to: 'your-email@here.com'
|
29
|
+
expect(@logmaster.email_config).to eq({ via: :sendmail, from: 'logmaster@localhost', subject: "Logmaster message", to: 'your-email@here.com' })
|
30
|
+
expect(@logmaster.instance_variable_get(:@email_log_level)).to eq(Logger::WARN)
|
30
31
|
end
|
31
32
|
|
32
33
|
it "sends log messages to each logger" do
|
@@ -37,13 +38,12 @@ describe Logmaster do
|
|
37
38
|
end
|
38
39
|
|
39
40
|
it "sends emails when the log level of a log message is appropriate" do
|
40
|
-
@logmaster.email_config = { to: 'your-email@here.com' }
|
41
|
-
@logmaster.log_level = Logger::WARN
|
41
|
+
@logmaster.email_config = { to: 'your-email@here.com', log_level: :warn }
|
42
42
|
|
43
|
-
expect(Pony).to receive(:mail)
|
43
|
+
expect(Pony).to receive(:mail).once
|
44
44
|
|
45
45
|
@logmaster.warn("WARNING bitches!") # Should call Pony.mail
|
46
|
-
@logmaster.
|
46
|
+
@logmaster.email_log_level = Logger::FATAL
|
47
47
|
@logmaster.warn("WARNING bitches!") # This time shouldn't, log_level is wrong
|
48
48
|
end
|
49
49
|
|