tee_logger 3.2.1 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +2 -0
- data/CHANGELOG.md +8 -0
- data/README.md +10 -5
- data/lib/tee_logger.rb +2 -2
- data/lib/tee_logger/configuration.rb +32 -3
- data/lib/tee_logger/constants.rb +11 -7
- data/lib/tee_logger/tee_logger_base.rb +15 -6
- data/lib/tee_logger/version.rb +1 -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: d28e952333c675499313816763f1faf5c908afde
|
4
|
+
data.tar.gz: 71321a829dffd0b7b6126722c449556232d1764d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16300440ff7dffdd75291528eb42ea1403ad72673e72fd87a5a35bd3ee5f2e422ab38cb88b96d6105ff8b009794e20d31386237d34d75c7f5cd8f8716edb126d
|
7
|
+
data.tar.gz: 08973e7cdf09bb898f9b984dd5786c24d4132c26defc05c28e6271d1b22f5727828de7ef73995152baf0ec03cecc1665728f8cba84106b4f0575d9ba900dbdc6
|
data/.rubocop_todo.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# v3.2.2
|
2
|
+
- [issue #17](https://github.com/k-ta-yamada/tee_logger/issues/17)
|
3
|
+
default settings for extend and include
|
4
|
+
|
5
|
+
# v3.2.1
|
6
|
+
- [issue #18](https://github.com/k-ta-yamada/tee_logger/issues/18)
|
7
|
+
use initial value `DEFAULT_FILE`, it's change TeeLogger.logdev
|
8
|
+
|
1
9
|
# v3.2.0
|
2
10
|
- [issue #15](https://github.com/k-ta-yamada/tee_logger/issues/15)
|
3
11
|
Before extend or include the module, allow the setting of logdev
|
data/README.md
CHANGED
@@ -169,15 +169,18 @@ module YourAwesomeModule
|
|
169
169
|
end
|
170
170
|
```
|
171
171
|
|
172
|
-
### logfile name
|
172
|
+
### configuration logfile name, progname, level, formatter, and datetime_format.
|
173
173
|
```ruby
|
174
174
|
require 'tee_logger'
|
175
175
|
|
176
|
-
# Before extend or include the module, allow the
|
177
|
-
# sorry, `TeeLogger.logev` is deprecate.
|
176
|
+
# Before extend or include the module, allow the configuration.
|
178
177
|
# TeeLogger.logdev = 'log1.log'
|
179
178
|
TeeLogger.configure do |config|
|
180
179
|
config.logdev = 'log1.log'
|
180
|
+
config.level = Logger::Severity::INFO
|
181
|
+
config.progname = 'AwesomeApp'
|
182
|
+
config.formatter = proc { |s, t, p, m| "#{s} #{t} #{p} #{m}\n" }
|
183
|
+
# config.datetime_format = '%Y%m%d %H%M%S '
|
181
184
|
end
|
182
185
|
|
183
186
|
class YourAwesomeClass
|
@@ -188,8 +191,10 @@ class YourAwesomeClass
|
|
188
191
|
end
|
189
192
|
end
|
190
193
|
|
191
|
-
#
|
192
|
-
|
194
|
+
# reset configuration
|
195
|
+
TeeLogger.configuration_reset
|
196
|
+
|
197
|
+
# NOTE: sorry, `TeeLogger.logev` is deprecate.
|
193
198
|
TeeLogger.logdev = 'log2.log'
|
194
199
|
module YourAwesomeModule
|
195
200
|
extend TeeLogger
|
data/lib/tee_logger.rb
CHANGED
@@ -25,7 +25,7 @@ module TeeLogger
|
|
25
25
|
mod.define_singleton_method(:logger) do
|
26
26
|
return @logger if @logger
|
27
27
|
@logger = TeeLogger.new
|
28
|
-
@logger.progname = mod
|
28
|
+
@logger.progname = TeeLogger.progname || mod
|
29
29
|
@logger
|
30
30
|
end
|
31
31
|
end
|
@@ -37,7 +37,7 @@ module TeeLogger
|
|
37
37
|
define_method(:logger) do
|
38
38
|
return @logger if @logger
|
39
39
|
@logger = TeeLogger.new
|
40
|
-
@logger.progname = klass.name
|
40
|
+
@logger.progname = TeeLogger.progname || klass.name
|
41
41
|
@logger
|
42
42
|
end
|
43
43
|
end
|
@@ -2,7 +2,18 @@
|
|
2
2
|
module TeeLogger
|
3
3
|
# configuration
|
4
4
|
module Configration
|
5
|
-
|
5
|
+
extend Gem::Deprecate
|
6
|
+
|
7
|
+
# @attr logdev [String, File]
|
8
|
+
# @attr level [Logger::Severity, Integer]
|
9
|
+
# @attr progname [String, Symbol]
|
10
|
+
# @attr formatter [Logger::Formatter, Proc]
|
11
|
+
# @attr datetime_format [String]
|
12
|
+
Configration = Struct.new(:logdev,
|
13
|
+
:level,
|
14
|
+
:progname,
|
15
|
+
:formatter,
|
16
|
+
:datetime_format)
|
6
17
|
|
7
18
|
# Yields the global configuration to a block.
|
8
19
|
# @yield [Configuration] global configuration
|
@@ -22,8 +33,6 @@ module TeeLogger
|
|
22
33
|
def logdev=(logdev)
|
23
34
|
configuration.logdev = logdev
|
24
35
|
end
|
25
|
-
|
26
|
-
extend Gem::Deprecate
|
27
36
|
deprecate :logdev=, 'TeeLogger.configure', 2016, 1
|
28
37
|
|
29
38
|
# @return [String, File] `configuration.logdev` or `DEFAULT_FILE`.
|
@@ -31,6 +40,26 @@ module TeeLogger
|
|
31
40
|
configuration.logdev || DEFAULT_FILE
|
32
41
|
end
|
33
42
|
|
43
|
+
# @return `configuration.level`
|
44
|
+
def level
|
45
|
+
configuration.level
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return `configuration.progname`
|
49
|
+
def progname
|
50
|
+
configuration.progname
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return `configuration.formatter`
|
54
|
+
def formatter
|
55
|
+
configuration.formatter
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return `configuration.datetime_format`
|
59
|
+
def datetime_format
|
60
|
+
configuration.datetime_format
|
61
|
+
end
|
62
|
+
|
34
63
|
private
|
35
64
|
|
36
65
|
def configuration
|
data/lib/tee_logger/constants.rb
CHANGED
@@ -1,23 +1,27 @@
|
|
1
1
|
# namespace
|
2
2
|
module TeeLogger
|
3
3
|
# no param of filename, set this filename
|
4
|
-
DEFAULT_FILE = './tee_logger.log'
|
4
|
+
DEFAULT_FILE = './tee_logger.log'.freeze
|
5
5
|
|
6
|
-
#
|
7
|
-
|
6
|
+
# configured attributes
|
7
|
+
CONFIGURED_ATTRIBUTES =
|
8
|
+
[:level, :progname, :formatter, :datetime_format].freeze
|
9
|
+
|
10
|
+
# implements targets
|
11
|
+
LOGGING_METHODS = [:debug, :info, :warn, :error, :fatal].freeze
|
8
12
|
|
9
13
|
# defined logdev names
|
10
|
-
LOGDEV_NAMES = [:console, :logfile]
|
14
|
+
LOGDEV_NAMES = [:console, :logfile].freeze
|
11
15
|
|
12
16
|
# defined paired of logdev name
|
13
|
-
LOGDEV_REVERSE = { console: :logfile, logfile: :console }
|
17
|
+
LOGDEV_REVERSE = { console: :logfile, logfile: :console }.freeze
|
14
18
|
|
15
19
|
# empty format
|
16
20
|
FORMATTER_FOR_DISABLING = proc { |_severity, _time, _progname, _msg| '' }
|
17
21
|
|
18
22
|
# using TeeLogger::Utils.extract_options
|
19
|
-
# @
|
20
|
-
# @
|
23
|
+
# @attr logdev_name [Symbol]
|
24
|
+
# @attr indent_level [Fixnum]
|
21
25
|
ParsedOption = Struct.new(:logdev_name, :indent_level)
|
22
26
|
|
23
27
|
# LOGDEV_NAMES not included error
|
@@ -37,7 +37,8 @@ module TeeLogger
|
|
37
37
|
end
|
38
38
|
|
39
39
|
include Utils
|
40
|
-
attr_reader :level, :progname, :formatter, :datetime_format
|
40
|
+
# attr_reader :level, :progname, :formatter, :datetime_format
|
41
|
+
attr_reader(*CONFIGURED_ATTRIBUTES)
|
41
42
|
|
42
43
|
# @param logdev [String]
|
43
44
|
# @param shift_age [Integer]
|
@@ -48,6 +49,7 @@ module TeeLogger
|
|
48
49
|
@logfile = Logger.new(logdev || TeeLogger.logdev, shift_age, shift_size)
|
49
50
|
|
50
51
|
@level, @progname, @formatter, @datetime_format = nil
|
52
|
+
configuration
|
51
53
|
end
|
52
54
|
|
53
55
|
define_logging_methods :debug
|
@@ -66,8 +68,8 @@ module TeeLogger
|
|
66
68
|
def level=(level)
|
67
69
|
@console.level = @logfile.level = @level = level
|
68
70
|
end
|
69
|
-
|
70
|
-
|
71
|
+
alias sev_threshold level
|
72
|
+
alias sev_threshold= level=
|
71
73
|
|
72
74
|
# @param name [String, Symbol]
|
73
75
|
def progname=(name = nil)
|
@@ -79,11 +81,11 @@ module TeeLogger
|
|
79
81
|
@console.formatter = @logfile.formatter = @formatter = formatter
|
80
82
|
end
|
81
83
|
|
82
|
-
# @param
|
83
|
-
def datetime_format=(
|
84
|
+
# @param datetime_format
|
85
|
+
def datetime_format=(datetime_format)
|
84
86
|
@console.datetime_format =
|
85
87
|
@logfile.datetime_format =
|
86
|
-
@datetime_format =
|
88
|
+
@datetime_format = datetime_format
|
87
89
|
end
|
88
90
|
|
89
91
|
# @param logdev_name [String, Symbol]
|
@@ -107,6 +109,13 @@ module TeeLogger
|
|
107
109
|
|
108
110
|
private
|
109
111
|
|
112
|
+
def configuration
|
113
|
+
CONFIGURED_ATTRIBUTES.each do |method_name|
|
114
|
+
value = TeeLogger.send(method_name)
|
115
|
+
send("#{method_name}=", value) unless value.nil?
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
110
119
|
def logging(name, progname, logdev_name = nil, &block)
|
111
120
|
if logdev_name
|
112
121
|
disable(logdev_name) { logging(name, progname, &block) }
|
data/lib/tee_logger/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tee_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k-ta-yamada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|