tee_logger 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +4 -3
- data/lib/tee_logger.rb +39 -19
- data/lib/tee_logger/version.rb +1 -1
- metadata +2 -2
- data/lib/tee_logger/base.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 663a9c80a5e899c9afa6337089e51c94578c9ef9
|
4
|
+
data.tar.gz: d5522bc64ca244eebfd8f26d43f9c3fdd891f100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b0d14d1bf676de05350d675cbbdd2ad1d92f3d28b8da8cff88b8889203cb08503dc863ef444d5b982c9620a12abed70dfe72268e486644330c853143bc8423e
|
7
|
+
data.tar.gz: 8f78b5ed0bd35f1c138568052cb6af38dbfb3ea4b8a4b937aa632966f96258f257fed680a83a02c5386cb90083aed6cf013a702ceef73a988be148f71302f43d
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
|
4
4
|
Sorry, I changed Usage.
|
5
5
|
|
6
|
-
- [
|
7
|
-
- [
|
6
|
+
- [Rubygems.org](https://rubygems.org/gems/tee_logger)
|
7
|
+
- [GitHub](https://github.com/k-ta-yamada/tee_logger)
|
8
8
|
|
9
9
|
# TeeLogger
|
10
10
|
|
@@ -49,7 +49,8 @@ tl.console.info('console only')
|
|
49
49
|
tl.logger.info('logger only')
|
50
50
|
```
|
51
51
|
|
52
|
-
|
52
|
+
## TODO feature
|
53
|
+
|
53
54
|
```
|
54
55
|
# disable and enable console output
|
55
56
|
tl.disable(:console)
|
data/lib/tee_logger.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'tee_logger/version'
|
2
2
|
require 'tee_logger/constants'
|
3
|
-
require 'tee_logger/base'
|
4
3
|
|
5
|
-
require '
|
4
|
+
require 'logger'
|
6
5
|
|
7
6
|
# namespace
|
8
7
|
module TeeLogger
|
@@ -12,33 +11,54 @@ module TeeLogger
|
|
12
11
|
end
|
13
12
|
|
14
13
|
class TeeLogger
|
15
|
-
extend Forwardable
|
16
|
-
|
17
14
|
attr_reader :logger, :console
|
18
15
|
|
19
16
|
def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@console = @base_logger.console
|
17
|
+
@logger = Logger.new(logdev, shift_age, shift_size)
|
18
|
+
@console = Logger.new(STDOUT)
|
23
19
|
end
|
24
20
|
|
25
21
|
# logging methods.
|
26
|
-
|
22
|
+
LOGGING_METHODS.each do |name|
|
23
|
+
define_method(name) do |progname = nil, &block|
|
24
|
+
@logger.send(name, progname, &block)
|
25
|
+
@console.send(name, progname, &block)
|
26
|
+
end
|
27
|
+
end
|
27
28
|
|
28
29
|
# check logging level methods.
|
29
|
-
|
30
|
+
LOGGING_METHODS.map { |v| "#{v}?" }.each do |name|
|
31
|
+
define_method(name) do
|
32
|
+
# TODO: which?
|
33
|
+
# @logger.send(name)
|
34
|
+
@console.send(name)
|
35
|
+
end
|
36
|
+
end
|
30
37
|
|
31
|
-
#
|
32
|
-
|
38
|
+
# TODO: Implement!
|
39
|
+
def disable(target)
|
40
|
+
# undef_method, remove_method ....
|
41
|
+
end
|
33
42
|
|
34
|
-
# TODO: Implement
|
35
|
-
|
36
|
-
|
43
|
+
# TODO: Implement!
|
44
|
+
def enable(target)
|
45
|
+
# undef_method, remove_method ....
|
46
|
+
end
|
47
|
+
|
48
|
+
def progname
|
49
|
+
# TODO: which?
|
50
|
+
# @logger.progname
|
51
|
+
@console.progname
|
52
|
+
end
|
53
|
+
|
54
|
+
def progname=(name = nil)
|
55
|
+
@logger.progname = name
|
56
|
+
@console.progname = name
|
57
|
+
end
|
37
58
|
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# def_delegators :@base_logger, :unknown, :unknown?
|
59
|
+
# def close
|
60
|
+
# @logger.close
|
61
|
+
# # @console.close
|
62
|
+
# end
|
43
63
|
end
|
44
64
|
end
|
data/lib/tee_logger/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tee_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k-ta-yamada
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- ".gitignore"
|
119
119
|
- ".rspec"
|
120
120
|
- ".travis.yml"
|
121
|
+
- CHANGELOG.md
|
121
122
|
- CODE_OF_CONDUCT.md
|
122
123
|
- Gemfile
|
123
124
|
- LICENSE.txt
|
@@ -126,7 +127,6 @@ files:
|
|
126
127
|
- bin/console
|
127
128
|
- bin/setup
|
128
129
|
- lib/tee_logger.rb
|
129
|
-
- lib/tee_logger/base.rb
|
130
130
|
- lib/tee_logger/constants.rb
|
131
131
|
- lib/tee_logger/version.rb
|
132
132
|
- tee_logger.gemspec
|
data/lib/tee_logger/base.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
|
3
|
-
# namespace
|
4
|
-
module TeeLogger
|
5
|
-
# base class
|
6
|
-
class Base
|
7
|
-
attr_reader :logger, :console
|
8
|
-
|
9
|
-
def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
10
|
-
@logger = Logger.new(logdev, shift_age, shift_size)
|
11
|
-
@console = Logger.new(STDOUT)
|
12
|
-
end
|
13
|
-
|
14
|
-
# logging methods.
|
15
|
-
LOGGING_METHODS.each do |name|
|
16
|
-
define_method(name) do |progname = nil, &block|
|
17
|
-
@logger.send(name, progname, &block)
|
18
|
-
@console.send(name, progname, &block)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# check logging level methods.
|
23
|
-
LOGGING_METHODS.map { |v| "#{v}?" }.each do |name|
|
24
|
-
define_method(name) do
|
25
|
-
@logger.send(name)
|
26
|
-
@console.send(name)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# TODO: Implement
|
31
|
-
def disable(target)
|
32
|
-
# undef_method, remove_method ....
|
33
|
-
end
|
34
|
-
|
35
|
-
# TODO: Implement
|
36
|
-
def enable(target)
|
37
|
-
# undef_method, remove_method ....
|
38
|
-
end
|
39
|
-
|
40
|
-
def progname
|
41
|
-
# TODO: which?
|
42
|
-
# @logger.progname
|
43
|
-
@console.progname
|
44
|
-
end
|
45
|
-
|
46
|
-
def progname=(name = nil)
|
47
|
-
@logger.progname = name
|
48
|
-
@console.progname = name
|
49
|
-
end
|
50
|
-
|
51
|
-
def close
|
52
|
-
@logger.close
|
53
|
-
# @console.close
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|