rails_use_case 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/rails/service.rb +23 -3
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 378667c4e3d11d0bcd91399781dad9059f27fe367d3ff0e2f318a4e7c50b8dd6
|
4
|
+
data.tar.gz: 9fc7f010004ef4978c2b8342c5682579dcb78333db7866e546513ccfc2869168
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64007c7637a4227673408117aa71b6e47182b36dfe18ec21d942bc7d1bcee4b2e99f8d2bd003ed50eed3868a047f6968f3c6d1f101a465101688507c319eac2f
|
7
|
+
data.tar.gz: 1d31a07cf8fef50723344aa175f121c0a7e3fd02937a4b2af29145402a9894ebce2de8e0d8915c0431dcad801bf1fa228988c677c511eb4edd4e80d629695ad4
|
data/README.md
CHANGED
@@ -176,8 +176,9 @@ which is available via the `config` method.
|
|
176
176
|
|
177
177
|
### Logging
|
178
178
|
|
179
|
-
|
180
|
-
|
179
|
+
Each service automatically logs to a separate log file `log/services/[service_name].log`. You can write additional logs via `logger.info(msg)`.
|
180
|
+
|
181
|
+
It's possible to force the services to log to STDOUT by setting the environment variable `SERVICE_LOGGER_STDOUT`. This is useful for Heroku for example.
|
181
182
|
|
182
183
|
|
183
184
|
## License
|
data/lib/rails/service.rb
CHANGED
@@ -50,9 +50,29 @@ module Rails
|
|
50
50
|
|
51
51
|
# Create the log file and sets @logger
|
52
52
|
private def setup_logger
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
if ENV['SERVICE_LOGGER_STDOUT']
|
54
|
+
setup_stdout_logger
|
55
|
+
else
|
56
|
+
log_path = Rails.root.join('log', 'services')
|
57
|
+
FileUtils.mkdir_p(log_path) unless Dir.exist?(log_path)
|
58
|
+
|
59
|
+
log_file = log_path.join("#{@service_name}.log").to_s
|
60
|
+
|
61
|
+
FileUtils.touch log_file
|
62
|
+
@logger = Logger.new(log_file)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
# Will setup the logger for logging to STDOUT. This can be useful for
|
68
|
+
# Heroku for example.
|
69
|
+
private def setup_stdout_logger
|
70
|
+
@logger = Logger.new(STDOUT)
|
71
|
+
|
72
|
+
@logger.formatter = proc do |severity, datetime, progname, msg|
|
73
|
+
msg = "[@service_name] #{msg}"
|
74
|
+
original_formatter.call(severity, datetime, progname, msg.dump)
|
75
|
+
end
|
56
76
|
end
|
57
77
|
|
58
78
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_use_case
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Klein
|
@@ -11,7 +11,7 @@ cert_chain: []
|
|
11
11
|
date: 2020-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: railties
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fakefs
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.2.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.13.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.13.0
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rake
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|