flexirest 1.3.3 → 1.3.4
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/CHANGELOG.md +6 -0
- data/lib/flexirest/logger.rb +24 -8
- data/lib/flexirest/version.rb +1 -1
- data/spec/lib/logger_spec.rb +15 -0
- 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: 5b8f5b60cec3d61fa565609de5a87d2dbcb93478
|
4
|
+
data.tar.gz: 0d500e6c2e4513ddd78c540037b64e7153d1c434
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce782dd60d2338981917cb27bba2d536cb45f4aa7650966bbca3bccd2facd9b7712a435a2ed30572eac985fd5d7b5deb34d43d7cffb87e376cddc70d07d5a9dc
|
7
|
+
data.tar.gz: 4288825a7cfc6a84e2950a06e3388d7417d6d4b022f9fcdd65e5945fc9b8158307ff4cfe8f820f7667a10572fb7c081f67be71f413c37572818ab4e9be598a6e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.3.4
|
4
|
+
|
5
|
+
Features:
|
6
|
+
|
7
|
+
- Allows assigning `STDOUT` to `Flexirest::Logger.logfile` which can be useful when debugging Flexirest or applications at the console (either `rails console` from a Rails app or `rake console` from within Flexirest's codebase) along with setting `verbose!` on the class.
|
8
|
+
|
3
9
|
## 1.3.3
|
4
10
|
|
5
11
|
Features:
|
data/lib/flexirest/logger.rb
CHANGED
@@ -20,8 +20,12 @@ module Flexirest
|
|
20
20
|
if defined?(Rails) && Rails.respond_to?(:logger)
|
21
21
|
Rails.logger.debug(message)
|
22
22
|
elsif @logfile
|
23
|
-
|
24
|
-
|
23
|
+
if @logfile.is_a?(String)
|
24
|
+
File.open(@logfile, "a") do |f|
|
25
|
+
f << "#{message}\n"
|
26
|
+
end
|
27
|
+
else
|
28
|
+
@logfile << "#{message}\n"
|
25
29
|
end
|
26
30
|
else
|
27
31
|
@messages << message
|
@@ -32,8 +36,12 @@ module Flexirest
|
|
32
36
|
if defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger
|
33
37
|
Rails.logger.info(message)
|
34
38
|
elsif @logfile
|
35
|
-
|
36
|
-
|
39
|
+
if @logfile.is_a?(String)
|
40
|
+
File.open(@logfile, "a") do |f|
|
41
|
+
f << "#{message}\n"
|
42
|
+
end
|
43
|
+
else
|
44
|
+
@logfile << "#{message}\n"
|
37
45
|
end
|
38
46
|
else
|
39
47
|
@messages << message
|
@@ -44,8 +52,12 @@ module Flexirest
|
|
44
52
|
if defined?(Rails) && Rails.respond_to?(:logger)
|
45
53
|
Rails.logger.warn(message)
|
46
54
|
elsif @logfile
|
47
|
-
|
48
|
-
|
55
|
+
if @logfile.is_a?(String)
|
56
|
+
File.open(@logfile, "a") do |f|
|
57
|
+
f << "#{message}\n"
|
58
|
+
end
|
59
|
+
else
|
60
|
+
@logfile << "#{message}\n"
|
49
61
|
end
|
50
62
|
else
|
51
63
|
@messages << message
|
@@ -56,8 +68,12 @@ module Flexirest
|
|
56
68
|
if defined?(Rails) && Rails.respond_to?(:logger)
|
57
69
|
Rails.logger.error(message)
|
58
70
|
elsif @logfile
|
59
|
-
|
60
|
-
|
71
|
+
if @logfile.is_a?(String)
|
72
|
+
File.open(@logfile, "a") do |f|
|
73
|
+
f << "#{message}\n"
|
74
|
+
end
|
75
|
+
else
|
76
|
+
@logfile << "#{message}\n"
|
61
77
|
end
|
62
78
|
else
|
63
79
|
@messages << message
|
data/lib/flexirest/version.rb
CHANGED
data/spec/lib/logger_spec.rb
CHANGED
@@ -47,6 +47,21 @@ describe Flexirest::Instrumentation do
|
|
47
47
|
Flexirest::Logger.warn("Hello warn")
|
48
48
|
end
|
49
49
|
|
50
|
+
it "should write to a logfile if one has been specified" do
|
51
|
+
Flexirest::Logger.logfile = STDOUT
|
52
|
+
expect(STDOUT).to receive(:<<).with("Hello world\n")
|
53
|
+
Flexirest::Logger.debug("Hello world")
|
54
|
+
|
55
|
+
expect(STDOUT).to receive(:<<).with("Hello info\n")
|
56
|
+
Flexirest::Logger.info("Hello info")
|
57
|
+
|
58
|
+
expect(STDOUT).to receive(:<<).with("Hello error\n")
|
59
|
+
Flexirest::Logger.error("Hello error")
|
60
|
+
|
61
|
+
expect(STDOUT).to receive(:<<).with("Hello warn\n")
|
62
|
+
Flexirest::Logger.warn("Hello warn")
|
63
|
+
end
|
64
|
+
|
50
65
|
it "should append to its own messages list if neither Rails nor a logfile has been specified" do
|
51
66
|
expect(File).not_to receive(:open)
|
52
67
|
Flexirest::Logger.debug("Hello world")
|