tee_logger 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +79 -79
- data/lib/tee_logger/base.rb +56 -56
- data/lib/tee_logger/constants.rb +7 -7
- data/lib/tee_logger/version.rb +4 -4
- data/lib/tee_logger.rb +44 -44
- data/tee_logger.gemspec +30 -30
- 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: 84e4ec4f5d0c713fe936c8eb1fe9193955ad7e97
|
4
|
+
data.tar.gz: b128ef2f454e2fe03b74ee3ad22c0cd7a2ad6d49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b1c06d8c44f9f479a6102c309b8d7071443147b0ecb0ba446ee23d8916a3b57d055f923b5518f0b6542c1b9665f863448e5ce8770a4c6645296e7272891747f
|
7
|
+
data.tar.gz: e18ae7de37e7bfcbcef531503b4d7ad18a8f6790dacacf8b498efe7e7fe9966fc8e93d8cee7ea870176b070002ef91d3d1962db8fcefcc96db609b912c2b1274
|
data/README.md
CHANGED
@@ -1,79 +1,79 @@
|
|
1
|
-
|
2
|
-
Sorry, I changed Usage.
|
3
|
-
|
4
|
-
- [rubygems](https://rubygems.org/gems/tee_logger)
|
5
|
-
- [github](https://github.com/k-ta-yamada/tee_logger)
|
6
|
-
|
7
|
-
# TeeLogger
|
8
|
-
|
9
|
-
logging to logfile and standard output.
|
10
|
-
|
11
|
-
Characteristic
|
12
|
-
- simple: use standard lib only.
|
13
|
-
- like Logger: see usage.
|
14
|
-
|
15
|
-
## Installation
|
16
|
-
|
17
|
-
Add this line to your application's Gemfile:
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
gem 'tee_logger'
|
21
|
-
```
|
22
|
-
|
23
|
-
And then execute:
|
24
|
-
|
25
|
-
$ bundle
|
26
|
-
|
27
|
-
Or install it yourself as:
|
28
|
-
|
29
|
-
$ gem install tee_logger
|
30
|
-
|
31
|
-
## Usage
|
32
|
-
|
33
|
-
```ruby
|
34
|
-
require 'tee_logger'
|
35
|
-
|
36
|
-
# Logger.new like options
|
37
|
-
tl = TeeLogger.new('./tee_logger.log', 5, 1_024)
|
38
|
-
|
39
|
-
tl.debug(:progname) { 'hello world' }
|
40
|
-
tl.progname = 'App'
|
41
|
-
tl.debug('hello tee_logger')
|
42
|
-
|
43
|
-
# console only
|
44
|
-
tl.console.info('console only')
|
45
|
-
|
46
|
-
# logfile only
|
47
|
-
tl.logger.info('logger only')
|
48
|
-
```
|
49
|
-
|
50
|
-
# TODO feature
|
51
|
-
```
|
52
|
-
# disable and enable console output
|
53
|
-
tl.disable(:console)
|
54
|
-
tl.info 'this message is logfile only'
|
55
|
-
tl.enable(:console)
|
56
|
-
tl.info 'this message is logfile and console'
|
57
|
-
|
58
|
-
# disable and enable logfile output
|
59
|
-
tl.disable(:logger)
|
60
|
-
tl.info 'this message is consle only'
|
61
|
-
tl.enable(:logger)
|
62
|
-
tl.info 'this message is logfile and console'
|
63
|
-
```
|
64
|
-
|
65
|
-
## Development
|
66
|
-
|
67
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
68
|
-
|
69
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
70
|
-
|
71
|
-
## Contributing
|
72
|
-
|
73
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/k-ta-yamada/tee_logger. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
74
|
-
|
75
|
-
|
76
|
-
## License
|
77
|
-
|
78
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
79
|
-
|
1
|
+
|
2
|
+
Sorry, I changed Usage.
|
3
|
+
|
4
|
+
- [rubygems](https://rubygems.org/gems/tee_logger)
|
5
|
+
- [github](https://github.com/k-ta-yamada/tee_logger)
|
6
|
+
|
7
|
+
# TeeLogger
|
8
|
+
|
9
|
+
logging to logfile and standard output.
|
10
|
+
|
11
|
+
Characteristic
|
12
|
+
- simple: use standard lib only.
|
13
|
+
- like Logger: see usage.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'tee_logger'
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install tee_logger
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'tee_logger'
|
35
|
+
|
36
|
+
# Logger.new like options
|
37
|
+
tl = TeeLogger.new('./tee_logger.log', 5, 1_024)
|
38
|
+
|
39
|
+
tl.debug(:progname) { 'hello world' }
|
40
|
+
tl.progname = 'App'
|
41
|
+
tl.debug('hello tee_logger')
|
42
|
+
|
43
|
+
# console only
|
44
|
+
tl.console.info('console only')
|
45
|
+
|
46
|
+
# logfile only
|
47
|
+
tl.logger.info('logger only')
|
48
|
+
```
|
49
|
+
|
50
|
+
# TODO feature
|
51
|
+
```
|
52
|
+
# disable and enable console output
|
53
|
+
tl.disable(:console)
|
54
|
+
tl.info 'this message is logfile only'
|
55
|
+
tl.enable(:console)
|
56
|
+
tl.info 'this message is logfile and console'
|
57
|
+
|
58
|
+
# disable and enable logfile output
|
59
|
+
tl.disable(:logger)
|
60
|
+
tl.info 'this message is consle only'
|
61
|
+
tl.enable(:logger)
|
62
|
+
tl.info 'this message is logfile and console'
|
63
|
+
```
|
64
|
+
|
65
|
+
## Development
|
66
|
+
|
67
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
68
|
+
|
69
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/k-ta-yamada/tee_logger. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
74
|
+
|
75
|
+
|
76
|
+
## License
|
77
|
+
|
78
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
79
|
+
|
data/lib/tee_logger/base.rb
CHANGED
@@ -1,56 +1,56 @@
|
|
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 |method_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}?" }
|
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
|
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 |method_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
|
data/lib/tee_logger/constants.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'logger'
|
2
|
-
|
3
|
-
# namespace
|
4
|
-
module TeeLogger
|
5
|
-
DEFAULT_FILE = './tee_logger.log'
|
6
|
-
LOGGING_METHODS = %i(debug info warn error fatal).freeze
|
7
|
-
end
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
# namespace
|
4
|
+
module TeeLogger
|
5
|
+
DEFAULT_FILE = './tee_logger.log'
|
6
|
+
LOGGING_METHODS = %i(debug info warn error fatal).freeze
|
7
|
+
end
|
data/lib/tee_logger/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# namespace
|
2
|
-
module TeeLogger
|
3
|
-
VERSION = '2.0.
|
4
|
-
end
|
1
|
+
# namespace
|
2
|
+
module TeeLogger
|
3
|
+
VERSION = '2.0.1'
|
4
|
+
end
|
data/lib/tee_logger.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
require 'tee_logger/version'
|
2
|
-
require 'tee_logger/constants'
|
3
|
-
require 'tee_logger/base'
|
4
|
-
|
5
|
-
require 'forwardable'
|
6
|
-
|
7
|
-
# namespace
|
8
|
-
module TeeLogger
|
9
|
-
# shortcut for TeeLogger::TeeLogger.new
|
10
|
-
def self.new(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
11
|
-
TeeLogger.new(logdev, shift_age, shift_size)
|
12
|
-
end
|
13
|
-
|
14
|
-
class TeeLogger
|
15
|
-
extend Forwardable
|
16
|
-
|
17
|
-
attr_reader :logger, :console
|
18
|
-
|
19
|
-
def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
20
|
-
@base_logger = Base.new(logdev, shift_age, shift_size)
|
21
|
-
@logger = @base_logger.logger
|
22
|
-
@console = @base_logger.console
|
23
|
-
end
|
24
|
-
|
25
|
-
# logging methods.
|
26
|
-
def_delegators :@base_logger, *LOGGING_METHODS
|
27
|
-
|
28
|
-
# check logging level methods.
|
29
|
-
def_delegators :@base_logger, *LOGGING_METHODS.map { |v| "#{v}?" }
|
30
|
-
|
31
|
-
# others.
|
32
|
-
def_delegators :@base_logger, :progname, :progname=
|
33
|
-
|
34
|
-
# TODO: Implement
|
35
|
-
# def_delegators :@base_logger, :datetime_format, :datetime_format=
|
36
|
-
# def_delegators :@base_logger, :formatter, :formatter=
|
37
|
-
|
38
|
-
# TODO: Implement
|
39
|
-
# def_delegator :@base_logger, :close
|
40
|
-
# def_delegators :@base_logger, :level, :sev_threshold
|
41
|
-
# def_delegators :@base_logger, :add, :log
|
42
|
-
# def_delegators :@base_logger, :unknown, :unknown?
|
43
|
-
end
|
44
|
-
end
|
1
|
+
require 'tee_logger/version'
|
2
|
+
require 'tee_logger/constants'
|
3
|
+
require 'tee_logger/base'
|
4
|
+
|
5
|
+
require 'forwardable'
|
6
|
+
|
7
|
+
# namespace
|
8
|
+
module TeeLogger
|
9
|
+
# shortcut for TeeLogger::TeeLogger.new
|
10
|
+
def self.new(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
11
|
+
TeeLogger.new(logdev, shift_age, shift_size)
|
12
|
+
end
|
13
|
+
|
14
|
+
class TeeLogger
|
15
|
+
extend Forwardable
|
16
|
+
|
17
|
+
attr_reader :logger, :console
|
18
|
+
|
19
|
+
def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
20
|
+
@base_logger = Base.new(logdev, shift_age, shift_size)
|
21
|
+
@logger = @base_logger.logger
|
22
|
+
@console = @base_logger.console
|
23
|
+
end
|
24
|
+
|
25
|
+
# logging methods.
|
26
|
+
def_delegators :@base_logger, *LOGGING_METHODS
|
27
|
+
|
28
|
+
# check logging level methods.
|
29
|
+
def_delegators :@base_logger, *LOGGING_METHODS.map { |v| "#{v}?" }
|
30
|
+
|
31
|
+
# others.
|
32
|
+
def_delegators :@base_logger, :progname, :progname=
|
33
|
+
|
34
|
+
# TODO: Implement
|
35
|
+
# def_delegators :@base_logger, :datetime_format, :datetime_format=
|
36
|
+
# def_delegators :@base_logger, :formatter, :formatter=
|
37
|
+
|
38
|
+
# TODO: Implement
|
39
|
+
# def_delegator :@base_logger, :close
|
40
|
+
# def_delegators :@base_logger, :level, :sev_threshold
|
41
|
+
# def_delegators :@base_logger, :add, :log
|
42
|
+
# def_delegators :@base_logger, :unknown, :unknown?
|
43
|
+
end
|
44
|
+
end
|
data/tee_logger.gemspec
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'tee_logger/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'tee_logger'
|
8
|
-
spec.version = TeeLogger::VERSION
|
9
|
-
spec.authors = ['k-ta-yamada']
|
10
|
-
spec.email = ['key.luvless@gmail.com']
|
11
|
-
|
12
|
-
spec.summary = 'logging to file and standard output'
|
13
|
-
spec.description = 'logging to file and standard output'
|
14
|
-
spec.homepage = 'https://github.com/k-ta-yamada/tee_logger'
|
15
|
-
spec.license = 'MIT'
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir = 'exe'
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ['lib']
|
21
|
-
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.10'
|
23
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
-
spec.add_development_dependency 'rspec'
|
25
|
-
|
26
|
-
spec.add_development_dependency 'pry'
|
27
|
-
spec.add_development_dependency 'pry-doc'
|
28
|
-
spec.add_development_dependency 'pry-theme'
|
29
|
-
spec.add_development_dependency 'rubocop'
|
30
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tee_logger/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'tee_logger'
|
8
|
+
spec.version = TeeLogger::VERSION
|
9
|
+
spec.authors = ['k-ta-yamada']
|
10
|
+
spec.email = ['key.luvless@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'logging to file and standard output'
|
13
|
+
spec.description = 'logging to file and standard output'
|
14
|
+
spec.homepage = 'https://github.com/k-ta-yamada/tee_logger'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'pry'
|
27
|
+
spec.add_development_dependency 'pry-doc'
|
28
|
+
spec.add_development_dependency 'pry-theme'
|
29
|
+
spec.add_development_dependency 'rubocop'
|
30
|
+
end
|