tee_logger 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +53 -50
- data/README.md +26 -8
- data/Rakefile +0 -2
- data/lib/tee_logger.rb +127 -120
- data/lib/tee_logger/version.rb +5 -5
- data/tee_logger.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbdb5ccee15e5eed47f3e89efbaac90990ce39f2
|
4
|
+
data.tar.gz: 152388538388e14fa2acc29cc3e0daab42a00419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd286237550da02a4a6db31bfdc2f9870f9397faa894abe9100a218ae542722430dae565c3cee70fa2f5a807f94d11d9ec1f77a12b9bfeabe5bce4381c68d1eb
|
7
|
+
data.tar.gz: 2da99911ebf7d6f02143df8d12b4160f9877a9572f9fd2b70fb5f7b7937e2e27d99f5383bc7e4168f0d436c0616bdcac8b22b959c15639fa33657459b604fbce
|
data/.travis.yml
CHANGED
@@ -5,3 +5,6 @@ rvm:
|
|
5
5
|
- 2.1.5
|
6
6
|
- 2.0.0
|
7
7
|
before_install: gem install bundler -v 1.10.4
|
8
|
+
notifications:
|
9
|
+
slack:
|
10
|
+
secure: zCs6tIIMRaugSasz857bnfcHywMZvz2nztcTJdkvi25kZFysakVgVJ+CNBRZSHjShsnBD1H1i3ywoECKPHUiLlUDQU4ncZQoSS0qM5CcmVlE0JOHzcvY2POTadZWfVn2XvRcCcoI2k7Oy9cS+xFmbs3PP2TqbVfPStB+l9jD+QejWinpLJR05PGi8M2iqZKjxAwJ9TBoLvmHt7UtXMq6edG/Q+SVOUQMEEkLCaWzSvNQYnDiTk1ewkXF0kG5jtVx/OKjQC62ioQIBz6+I6aMfOil2MCpb8u37asXQeML/rMPfBxVuwvBSwGKpRBrJSUG5XeoWg8bbri0WUOrOGCg3LVRtdiHyUNcAYObaB69+YqFOt/F05Dgg6+9Rs53mgZM2zuvsFp2qeSD27wXCy0ZJhFyMv5YJA5paJZjOAH0ki9FWeZjC4XMasntvO7/83rCEFcqGusMckLKcKE/RdEYurzqLruF2W4FGSAvSTbARjQbtYMxmuh1xJrH4KCdCYDvoxYb4xJrGo+q77j+wnpzGBwf8nak2VcGgN6wXadeosNR31WGW+HBwv8LxTJutlXzDjBTyK2ZcaaIZASbF3liEH294ycdf9YcGlxZYxuauPsg0EXa8C0NHXkfL9Zb1CftEgULXvtBL/qNDr/cyhHWbSYZcJw5DfQYt6inBKudmEU=
|
data/CHANGELOG.md
CHANGED
@@ -1,50 +1,53 @@
|
|
1
|
-
# v2.
|
2
|
-
-
|
3
|
-
|
4
|
-
# v2.
|
5
|
-
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
-
|
15
|
-
|
16
|
-
# v2.
|
17
|
-
-
|
18
|
-
|
19
|
-
# v2.3.
|
20
|
-
-
|
21
|
-
|
22
|
-
|
23
|
-
-
|
24
|
-
|
25
|
-
|
26
|
-
-
|
27
|
-
|
28
|
-
# v2.
|
29
|
-
-
|
30
|
-
|
31
|
-
|
32
|
-
-
|
33
|
-
|
34
|
-
|
35
|
-
-
|
36
|
-
|
37
|
-
# v2.0
|
38
|
-
-
|
39
|
-
|
40
|
-
# v2.0.
|
41
|
-
- bugfix
|
42
|
-
|
43
|
-
# v2.0.
|
44
|
-
-
|
45
|
-
|
46
|
-
#
|
47
|
-
-
|
48
|
-
|
49
|
-
# v1.
|
50
|
-
-
|
1
|
+
# v2.7.0
|
2
|
+
- add datetime_format, datetime_format=
|
3
|
+
|
4
|
+
# v2.6.0
|
5
|
+
- disabling option add to logging_methods
|
6
|
+
|
7
|
+
# v2.5.0
|
8
|
+
- level, progname and formatter were changed to instance variable
|
9
|
+
- refactoring: disabling and enabling
|
10
|
+
- rm ./lib/tee_logger/constants.rb. Constants move to ./lib/tee_logger.rb
|
11
|
+
|
12
|
+
# v2.4.1
|
13
|
+
- update README.md
|
14
|
+
- and YARD comment
|
15
|
+
|
16
|
+
# v2.4.0
|
17
|
+
- TeeLogger#disable is allow block given
|
18
|
+
|
19
|
+
# v2.3.1
|
20
|
+
- refactoring TeeLogger#disable
|
21
|
+
|
22
|
+
# v2.3.0
|
23
|
+
- remove TeeLogger.attr_reader
|
24
|
+
- and rename instance variable: @logger => @logfile
|
25
|
+
- implementation `#level` and `level=`
|
26
|
+
- implementation `#formatter` and `formatter=`
|
27
|
+
|
28
|
+
# v2.2.0
|
29
|
+
- disabling and enabling
|
30
|
+
|
31
|
+
# v2.1.1
|
32
|
+
- refactoring of test case
|
33
|
+
- Introduced capture_stdout
|
34
|
+
- Introduced FakeFS
|
35
|
+
- Change logdev of Console for Logger from STDOUT to $ stdout
|
36
|
+
|
37
|
+
# v2.1.0
|
38
|
+
- Integrate TeeLogger::Base class to TeeLogger::TeeLogger class
|
39
|
+
|
40
|
+
# v2.0.2
|
41
|
+
- bugfix
|
42
|
+
|
43
|
+
# v2.0.1
|
44
|
+
- bugfix
|
45
|
+
|
46
|
+
# v2.0.0
|
47
|
+
- Change to Class from Module
|
48
|
+
|
49
|
+
# v1.1.0
|
50
|
+
- bugfix
|
51
|
+
|
52
|
+
# v1.0.0
|
53
|
+
- first
|
data/README.md
CHANGED
@@ -57,6 +57,10 @@ tl.debug(:progname) { 'hello world' }
|
|
57
57
|
tl.progname = 'App'
|
58
58
|
tl.debug 'hello tee_logger'
|
59
59
|
|
60
|
+
# disable only when specified
|
61
|
+
tl.info 'this message is logfile only', :console
|
62
|
+
tl.info 'this message is console only', :logfile
|
63
|
+
|
60
64
|
# disable console output
|
61
65
|
tl.disable(:console)
|
62
66
|
tl.info 'this message is logfile only'
|
@@ -81,30 +85,44 @@ tl.info 'this message is logfile and console'
|
|
81
85
|
|
82
86
|
# and others like Logger's
|
83
87
|
tl.debug? # => true
|
84
|
-
tl.info?
|
85
|
-
tl.warn?
|
86
|
-
tl.error?
|
87
|
-
tl.fatal?
|
88
|
+
tl.info? # => true
|
89
|
+
tl.warn? # => true
|
90
|
+
tl.error? # => true
|
91
|
+
tl.fatal? # => true
|
88
92
|
|
89
93
|
tl.level # => 0
|
90
94
|
tl.level = Logger::INFO
|
91
95
|
tl.debug 'this message is not logging'
|
92
96
|
|
93
97
|
tl.formatter # => nil or Proc
|
94
|
-
tl.formatter = proc {|severity, datetime, progname, message| "#{severity}:#{message}" }
|
98
|
+
tl.formatter = proc { |severity, datetime, progname, message| "#{severity}:#{message}" }
|
99
|
+
|
100
|
+
tl.datetime_format # => nil or Proc
|
101
|
+
tl.datetime_format = '%Y%m%d %H%M%S '
|
95
102
|
```
|
96
103
|
|
97
104
|
|
98
105
|
## Development
|
99
106
|
|
100
|
-
After checking out the repo, run `
|
107
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
108
|
+
Then, run `rake rspec` to run the tests.
|
109
|
+
You can also run `budle exec pry -r ./lib/tee_logger` for an interactive prompt
|
110
|
+
that will allow you to experiment.
|
101
111
|
|
102
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
112
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
113
|
+
To release a new version, update the version number in `version.rb`,
|
114
|
+
and then run `bundle exec rake release`,
|
115
|
+
which will create a git tag for the version,
|
116
|
+
push git commits and tags,
|
117
|
+
and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
103
118
|
|
104
119
|
|
105
120
|
## Contributing
|
106
121
|
|
107
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/k-ta-yamada/tee_logger.
|
122
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/k-ta-yamada/tee_logger.
|
123
|
+
This project is intended to be a safe,
|
124
|
+
welcoming space for collaboration,
|
125
|
+
and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
108
126
|
|
109
127
|
|
110
128
|
## License
|
data/Rakefile
CHANGED
data/lib/tee_logger.rb
CHANGED
@@ -1,120 +1,127 @@
|
|
1
|
-
require 'tee_logger/version'
|
2
|
-
require 'logger'
|
3
|
-
|
4
|
-
# namespace
|
5
|
-
module TeeLogger
|
6
|
-
# no param of filename, set this filename
|
7
|
-
DEFAULT_FILE = './tee_logger.log'
|
8
|
-
# Implements targets
|
9
|
-
LOGGING_METHODS = [:debug, :info, :warn, :error, :fatal].freeze
|
10
|
-
|
11
|
-
# shortcut for TeeLogger::TeeLogger.new
|
12
|
-
# @see TeeLogger
|
13
|
-
def self.new(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
14
|
-
TeeLogger.new(logdev, shift_age, shift_size)
|
15
|
-
end
|
16
|
-
|
17
|
-
# main
|
18
|
-
# @see http://www.rubydoc.info/stdlib/logger/Logger Logger
|
19
|
-
class TeeLogger
|
20
|
-
class << self
|
21
|
-
# @!macro [attach] logging_methods
|
22
|
-
# @!method $1(progname = nil, disabling_target = nil, &block)
|
23
|
-
# logging $1 level message.
|
24
|
-
# @param progname see also Logger
|
25
|
-
# @param disabling_target (Symbol) valid values => [:console, :logfile]
|
26
|
-
# @param &block see also Logger
|
27
|
-
# @return true
|
28
|
-
# @see Logger
|
29
|
-
def define_logging_methods(name)
|
30
|
-
define_method(name) do |progname = nil, disabling_target = nil, &block|
|
31
|
-
if disabling_target
|
32
|
-
disable(disabling_target) { logging(name, progname, &block) }
|
33
|
-
else
|
34
|
-
logging(name, progname, &block)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
private :define_logging_methods
|
39
|
-
|
40
|
-
# @!macro [attach] loglevel_check_methods
|
41
|
-
# @!method $1(name)
|
42
|
-
# @return [Boolean]
|
43
|
-
def define_loglevel_check_methods(name)
|
44
|
-
define_method(name) do
|
45
|
-
@console.send(name)
|
46
|
-
@logfile.send(name)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
private :define_loglevel_check_methods
|
50
|
-
end
|
51
|
-
|
52
|
-
attr_reader :level, :progname, :formatter
|
53
|
-
|
54
|
-
# @param logdev [String]
|
55
|
-
# @param shift_age [Integer]
|
56
|
-
# @param shift_size [Integer]
|
57
|
-
# @see Logger#initialize
|
58
|
-
def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
59
|
-
@console = Logger.new($stdout)
|
60
|
-
@logfile = Logger.new(logdev, shift_age, shift_size)
|
61
|
-
end
|
62
|
-
|
63
|
-
define_logging_methods :debug
|
64
|
-
define_logging_methods :info
|
65
|
-
define_logging_methods :warn
|
66
|
-
define_logging_methods :error
|
67
|
-
define_logging_methods :fatal
|
68
|
-
|
69
|
-
define_loglevel_check_methods :debug?
|
70
|
-
define_loglevel_check_methods :info?
|
71
|
-
define_loglevel_check_methods :warn?
|
72
|
-
define_loglevel_check_methods :error?
|
73
|
-
define_loglevel_check_methods :fatal?
|
74
|
-
|
75
|
-
# @param level [Integer]
|
76
|
-
def level=(level)
|
77
|
-
@console.level = @logfile.level = @level = level
|
78
|
-
end
|
79
|
-
alias_method :sev_threshold, :level
|
80
|
-
alias_method :sev_threshold=, :level=
|
81
|
-
|
82
|
-
# @param name [String, Symbol]
|
83
|
-
def progname=(name = nil)
|
84
|
-
@console.progname = @logfile.progname = @progname = name
|
85
|
-
end
|
86
|
-
|
87
|
-
# @param formatter
|
88
|
-
def formatter=(formatter)
|
89
|
-
@console.formatter = @logfile.formatter = @formatter = formatter
|
90
|
-
end
|
91
|
-
|
92
|
-
# @param
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
1
|
+
require 'tee_logger/version'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
# namespace
|
5
|
+
module TeeLogger
|
6
|
+
# no param of filename, set this filename
|
7
|
+
DEFAULT_FILE = './tee_logger.log'
|
8
|
+
# Implements targets
|
9
|
+
LOGGING_METHODS = [:debug, :info, :warn, :error, :fatal].freeze
|
10
|
+
|
11
|
+
# shortcut for TeeLogger::TeeLogger.new
|
12
|
+
# @see TeeLogger
|
13
|
+
def self.new(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
14
|
+
TeeLogger.new(logdev, shift_age, shift_size)
|
15
|
+
end
|
16
|
+
|
17
|
+
# main
|
18
|
+
# @see http://www.rubydoc.info/stdlib/logger/Logger Logger
|
19
|
+
class TeeLogger
|
20
|
+
class << self
|
21
|
+
# @!macro [attach] logging_methods
|
22
|
+
# @!method $1(progname = nil, disabling_target = nil, &block)
|
23
|
+
# logging $1 level message.
|
24
|
+
# @param progname see also Logger
|
25
|
+
# @param disabling_target (Symbol) valid values => [:console, :logfile]
|
26
|
+
# @param &block see also Logger
|
27
|
+
# @return true
|
28
|
+
# @see Logger
|
29
|
+
def define_logging_methods(name)
|
30
|
+
define_method(name) do |progname = nil, disabling_target = nil, &block|
|
31
|
+
if disabling_target
|
32
|
+
disable(disabling_target) { logging(name, progname, &block) }
|
33
|
+
else
|
34
|
+
logging(name, progname, &block)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
private :define_logging_methods
|
39
|
+
|
40
|
+
# @!macro [attach] loglevel_check_methods
|
41
|
+
# @!method $1(name)
|
42
|
+
# @return [Boolean]
|
43
|
+
def define_loglevel_check_methods(name)
|
44
|
+
define_method(name) do
|
45
|
+
@console.send(name)
|
46
|
+
@logfile.send(name)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
private :define_loglevel_check_methods
|
50
|
+
end
|
51
|
+
|
52
|
+
attr_reader :level, :progname, :formatter, :datetime_format
|
53
|
+
|
54
|
+
# @param logdev [String]
|
55
|
+
# @param shift_age [Integer]
|
56
|
+
# @param shift_size [Integer]
|
57
|
+
# @see Logger#initialize
|
58
|
+
def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
59
|
+
@console = Logger.new($stdout)
|
60
|
+
@logfile = Logger.new(logdev, shift_age, shift_size)
|
61
|
+
end
|
62
|
+
|
63
|
+
define_logging_methods :debug
|
64
|
+
define_logging_methods :info
|
65
|
+
define_logging_methods :warn
|
66
|
+
define_logging_methods :error
|
67
|
+
define_logging_methods :fatal
|
68
|
+
|
69
|
+
define_loglevel_check_methods :debug?
|
70
|
+
define_loglevel_check_methods :info?
|
71
|
+
define_loglevel_check_methods :warn?
|
72
|
+
define_loglevel_check_methods :error?
|
73
|
+
define_loglevel_check_methods :fatal?
|
74
|
+
|
75
|
+
# @param level [Integer]
|
76
|
+
def level=(level)
|
77
|
+
@console.level = @logfile.level = @level = level
|
78
|
+
end
|
79
|
+
alias_method :sev_threshold, :level
|
80
|
+
alias_method :sev_threshold=, :level=
|
81
|
+
|
82
|
+
# @param name [String, Symbol]
|
83
|
+
def progname=(name = nil)
|
84
|
+
@console.progname = @logfile.progname = @progname = name
|
85
|
+
end
|
86
|
+
|
87
|
+
# @param formatter
|
88
|
+
def formatter=(formatter)
|
89
|
+
@console.formatter = @logfile.formatter = @formatter = formatter
|
90
|
+
end
|
91
|
+
|
92
|
+
# @param formatter
|
93
|
+
def datetime_format=(format)
|
94
|
+
@console.datetime_format =
|
95
|
+
@logfile.datetime_format =
|
96
|
+
@datetime_format = format
|
97
|
+
end
|
98
|
+
|
99
|
+
# @param logdev_name [String, Symbol]
|
100
|
+
# @yield before logdev_name disable, after logdev_name enable.
|
101
|
+
def disable(logdev_name)
|
102
|
+
if block_given?
|
103
|
+
disable(logdev_name)
|
104
|
+
yield
|
105
|
+
enable(logdev_name)
|
106
|
+
else
|
107
|
+
logdev_instance(logdev_name).formatter = proc { |_, _, _, _| '' }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# @param logdev_name [String, Symbol]
|
112
|
+
def enable(logdev_name)
|
113
|
+
logdev_instance(logdev_name).formatter = @formatter
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def logging(name, progname, &block)
|
119
|
+
@console.send(name, progname, &block)
|
120
|
+
@logfile.send(name, progname, &block)
|
121
|
+
end
|
122
|
+
|
123
|
+
def logdev_instance(logdev_name)
|
124
|
+
instance_variable_get("@#{logdev_name}")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
data/lib/tee_logger/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# namespace
|
2
|
-
module TeeLogger
|
3
|
-
# version number
|
4
|
-
VERSION = '2.
|
5
|
-
end
|
1
|
+
# namespace
|
2
|
+
module TeeLogger
|
3
|
+
# version number
|
4
|
+
VERSION = '2.7.0'
|
5
|
+
end
|
data/tee_logger.gemspec
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: 2.
|
4
|
+
version: 2.7.0
|
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: 2015-09-
|
11
|
+
date: 2015-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: parallel
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
description: logging to file and standard output. require standard library only.
|
154
168
|
email:
|
155
169
|
- key.luvless@gmail.com
|