ext_logger 0.2.5 → 0.2.6
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/README.md +2 -1
- data/lib/ext_logger/common.rb +30 -20
- data/lib/ext_logger/main.rb +3 -3
- data/lib/ext_logger/version.rb +1 -1
- 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: f7b52578e0d1dd8b405191152fcc16a65a9f84a6
|
4
|
+
data.tar.gz: 6d3fda78d2f55209df32c43a5b6d6573b7b89933
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be472dbce0c752964c7b3c1bd4c6c8982011fcaa6a7bc88d61bd8e39e588bbcab07e1243b0447071e5cbd2f637561d0f7d7877a72153439ae46223a1e3cf6bc0
|
7
|
+
data.tar.gz: 2f278f1b6d81814dc33490ed46fd8464508075d5e9dc3a9a6198fe571a9c046c01894096efd17ceed063cd7bc910d66b92d68991e70796fb323e28283ba7c291
|
data/README.md
CHANGED
@@ -5,9 +5,10 @@ Welcome to your new gem! In this directory, you'll find the files you need to be
|
|
5
5
|
```explain
|
6
6
|
Extended Logger class, log output to console in non-production environment.
|
7
7
|
Other extensions see version updates.
|
8
|
-
2019-01-22(0.2.
|
8
|
+
2019-01-22(0.2.6):
|
9
9
|
Fix some bugs.
|
10
10
|
Add method: analysis_exception to Common module.
|
11
|
+
Fix module extend class method bug.
|
11
12
|
|
12
13
|
2019-01-21(0.2.4):
|
13
14
|
Fix some bugs.
|
data/lib/ext_logger/common.rb
CHANGED
@@ -2,6 +2,36 @@ class ExtLogger
|
|
2
2
|
|
3
3
|
module Common
|
4
4
|
|
5
|
+
ENV_HASH = {
|
6
|
+
dev: 'development',
|
7
|
+
stg: 'staging',
|
8
|
+
pro: 'production',
|
9
|
+
}
|
10
|
+
|
11
|
+
def self.included(base)
|
12
|
+
# base.send(:include, InstanceMethods)
|
13
|
+
base.extend ClassMethods
|
14
|
+
# base.class_eval do
|
15
|
+
# scope :active, where(is_active: true)
|
16
|
+
# end
|
17
|
+
end
|
18
|
+
|
19
|
+
module ClassMethods
|
20
|
+
# Validation the Rails object
|
21
|
+
def valid_rails
|
22
|
+
defined?(::Rails)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get the path of folder or rails project
|
26
|
+
def rails_root
|
27
|
+
self.valid_rails && ::Rails.root ? ::Rails.root.to_s : ::Dir.pwd
|
28
|
+
end
|
29
|
+
# Get the env
|
30
|
+
def rails_env
|
31
|
+
self.valid_rails && ::Rails.env ? ::Rails.env : ENV_HASH[:dev]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
5
35
|
# Get class name
|
6
36
|
def get_class_name
|
7
37
|
self.class.to_s
|
@@ -26,26 +56,6 @@ class ExtLogger
|
|
26
56
|
puts "DEBUG_P: #{str}" if @debug
|
27
57
|
end
|
28
58
|
|
29
|
-
# Validation the Rails object
|
30
|
-
def valid_rails
|
31
|
-
defined?(::Rails)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Get the path of folder or rails project
|
35
|
-
def rails_root
|
36
|
-
valid_rails && ::Rails.root ? ::Rails.root.to_s : ::Dir.pwd
|
37
|
-
end
|
38
|
-
|
39
|
-
ENV_HASH = {
|
40
|
-
dev: 'development',
|
41
|
-
stg: 'staging',
|
42
|
-
pro: 'production',
|
43
|
-
}
|
44
|
-
# Get the env
|
45
|
-
def rails_env
|
46
|
-
valid_rails && ::Rails.env ? ::Rails.env : ENV_HASH[:dev]
|
47
|
-
end
|
48
|
-
|
49
59
|
# Analysis exception object
|
50
60
|
def analysis_exception(e)
|
51
61
|
func_name = "[common.#{__method__.to_s}]"
|
data/lib/ext_logger/main.rb
CHANGED
@@ -189,8 +189,8 @@ class ExtLogger
|
|
189
189
|
_path = path
|
190
190
|
set_path(_path)
|
191
191
|
# if path.is_a?(String)
|
192
|
-
# if path.include?(rails_root)
|
193
|
-
# _path = path.gsub(rails_root, '')
|
192
|
+
# if path.include?(ExtLogger.rails_root)
|
193
|
+
# _path = path.gsub(ExtLogger.rails_root, '')
|
194
194
|
# _path = '/log/' + _path if !_path.include?('log/')
|
195
195
|
# _path = _path.gsub('//', '/')
|
196
196
|
# else
|
@@ -312,7 +312,7 @@ class ExtLogger
|
|
312
312
|
def output_normal(*args)
|
313
313
|
func_name = "[#{get_class_name}:private output_normal]"
|
314
314
|
_flag = false
|
315
|
-
_flag = rails_env != ENV_HASH[:pro] if @output_flag
|
315
|
+
_flag = ExtLogger.rails_env != ENV_HASH[:pro] if @output_flag
|
316
316
|
|
317
317
|
if args.size > 1
|
318
318
|
output_debug "#{func_name} *args: #{args}"
|
data/lib/ext_logger/version.rb
CHANGED