tee_logger 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +57 -12
- data/.travis.yml +7 -7
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +13 -13
- data/Gemfile +6 -6
- data/LICENSE.txt +21 -21
- data/README.md +112 -112
- data/Rakefile +6 -6
- data/lib/tee_logger/version.rb +1 -1
- data/lib/tee_logger.rb +40 -34
- data/tee_logger.gemspec +38 -38
- 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: db9ff72237e7333f61ca1fe18042003209fb483b
|
4
|
+
data.tar.gz: 6ab586d12562c36af63939d276449e2f229cc3ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7b0426ad4f79239ca3cf1fddfee097b3470f16555e792cbe072062eb33c35c7c632d0064964aea9cfbade8c1b160bd4ad92aea28bfeb52be93667c73331a711
|
7
|
+
data.tar.gz: 4e45ef83df1923a06ef5b9461d1cc835031b63ceac080c76f092f52def1cfb8106fcac5a472ef02614f4c7d3f23419372daef575efc528ef76f0e62a886182de
|
data/.gitignore
CHANGED
@@ -1,12 +1,57 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/Gemfile.lock
|
4
|
-
/_yardoc/
|
5
|
-
/coverage/
|
6
|
-
/doc/
|
7
|
-
/pkg/
|
8
|
-
/spec/reports/
|
9
|
-
/tmp/
|
10
|
-
|
11
|
-
/vendor
|
12
|
-
tee_logger.log
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
|
11
|
+
/vendor
|
12
|
+
tee_logger.log
|
13
|
+
|
14
|
+
### https://raw.github.com/github/gitignore/d7161533f13c64dd677d367be369f4e900f5b4ea/Global/OSX.gitignore
|
15
|
+
|
16
|
+
.DS_Store
|
17
|
+
.AppleDouble
|
18
|
+
.LSOverride
|
19
|
+
|
20
|
+
# Icon must end with two \r
|
21
|
+
Icon
|
22
|
+
|
23
|
+
# Thumbnails
|
24
|
+
._*
|
25
|
+
|
26
|
+
# Files that might appear on external disk
|
27
|
+
.Spotlight-V100
|
28
|
+
.Trashes
|
29
|
+
|
30
|
+
# Directories potentially created on remote AFP share
|
31
|
+
.AppleDB
|
32
|
+
.AppleDesktop
|
33
|
+
Network Trash Folder
|
34
|
+
Temporary Items
|
35
|
+
.apdisk
|
36
|
+
|
37
|
+
|
38
|
+
### https://raw.github.com/github/gitignore/d7161533f13c64dd677d367be369f4e900f5b4ea/Global/Windows.gitignore
|
39
|
+
|
40
|
+
# Windows image file caches
|
41
|
+
Thumbs.db
|
42
|
+
ehthumbs.db
|
43
|
+
|
44
|
+
# Folder config file
|
45
|
+
Desktop.ini
|
46
|
+
|
47
|
+
# Recycle Bin used on file shares
|
48
|
+
$RECYCLE.BIN/
|
49
|
+
|
50
|
+
# Windows Installer files
|
51
|
+
*.cab
|
52
|
+
*.msi
|
53
|
+
*.msm
|
54
|
+
*.msp
|
55
|
+
|
56
|
+
# Windows shortcuts
|
57
|
+
*.lnk
|
data/.travis.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- ruby-head
|
4
|
-
- 2.2.2
|
5
|
-
- 2.1.5
|
6
|
-
- 2.0.0
|
7
|
-
before_install: gem install bundler -v 1.10.4
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- ruby-head
|
4
|
+
- 2.2.2
|
5
|
+
- 2.1.5
|
6
|
+
- 2.0.0
|
7
|
+
before_install: gem install bundler -v 1.10.4
|
data/CHANGELOG.md
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
# Contributor Code of Conduct
|
2
|
-
|
3
|
-
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
-
|
5
|
-
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
-
|
7
|
-
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
-
|
9
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
-
|
11
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
-
|
13
|
-
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in tee_logger.gemspec
|
4
|
-
gemspec
|
5
|
-
gem 'codeclimate-test-reporter', group: :test, require: nil
|
6
|
-
gem 'simplecov-console', group: :test, require: nil
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in tee_logger.gemspec
|
4
|
+
gemspec
|
5
|
+
gem 'codeclimate-test-reporter', group: :test, require: nil
|
6
|
+
gem 'simplecov-console', group: :test, require: nil
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015 k-ta-yamada
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 k-ta-yamada
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,112 +1,112 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/tee_logger.svg)](http://badge.fury.io/rb/tee_logger)
|
2
|
-
[![Build Status](https://travis-ci.org/k-ta-yamada/tee_logger.svg)](https://travis-ci.org/k-ta-yamada/tee_logger)
|
3
|
-
[![Code Climate](https://codeclimate.com/github/k-ta-yamada/tee_logger/badges/gpa.svg)](https://codeclimate.com/github/k-ta-yamada/tee_logger)
|
4
|
-
[![Test Coverage](https://codeclimate.com/github/k-ta-yamada/tee_logger/badges/coverage.svg)](https://codeclimate.com/github/k-ta-yamada/tee_logger/coverage)
|
5
|
-
|
6
|
-
> Sorry, I changed Usage from version 2.0.0
|
7
|
-
|
8
|
-
- [Rubygems.org](https://rubygems.org/gems/tee_logger)
|
9
|
-
- [GitHub](https://github.com/k-ta-yamada/tee_logger)
|
10
|
-
- [RubyDoc.info](http://www.rubydoc.info/gems/tee_logger)
|
11
|
-
|
12
|
-
# TeeLogger
|
13
|
-
|
14
|
-
logging to file and standard output.
|
15
|
-
require standard library only.
|
16
|
-
|
17
|
-
|
18
|
-
## Characteristic
|
19
|
-
|
20
|
-
- simple: use standard lib only.
|
21
|
-
- like Logger: see usage.
|
22
|
-
- enabled or disabled by switching the output of the console and the logfile.
|
23
|
-
|
24
|
-
|
25
|
-
## Installation
|
26
|
-
|
27
|
-
Add this line to your application's Gemfile:
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
gem 'tee_logger'
|
31
|
-
```
|
32
|
-
|
33
|
-
And then execute:
|
34
|
-
|
35
|
-
$ bundle
|
36
|
-
|
37
|
-
Or install it yourself as:
|
38
|
-
|
39
|
-
$ gem install tee_logger
|
40
|
-
|
41
|
-
|
42
|
-
## Usage
|
43
|
-
|
44
|
-
```ruby
|
45
|
-
require 'tee_logger'
|
46
|
-
|
47
|
-
# Logger.new like options(logdev, shift_age, shift_size)
|
48
|
-
# options default value is
|
49
|
-
# logdev = './tee_logger.log'
|
50
|
-
# shift_age = 0
|
51
|
-
# shift_size = 1_048_576
|
52
|
-
tl = TeeLogger.new
|
53
|
-
|
54
|
-
# let's logging
|
55
|
-
tl.debug 'hello'
|
56
|
-
tl.debug(:progname) { 'hello world' }
|
57
|
-
tl.progname = 'App'
|
58
|
-
tl.debug 'hello tee_logger'
|
59
|
-
|
60
|
-
# disable console output
|
61
|
-
tl.disable(:console)
|
62
|
-
tl.info 'this message is logfile only'
|
63
|
-
|
64
|
-
# enable console output
|
65
|
-
tl.enable(:console)
|
66
|
-
tl.info 'this message is logfile and console'
|
67
|
-
|
68
|
-
# disable logfile output
|
69
|
-
tl.disable(:logfile)
|
70
|
-
tl.info 'this message is consle only'
|
71
|
-
|
72
|
-
# enable logfile output
|
73
|
-
tl.enable(:logfile)
|
74
|
-
tl.info 'this message is logfile and console'
|
75
|
-
|
76
|
-
# disabe in block
|
77
|
-
tl.disable(:console) do
|
78
|
-
tl.info 'this message is logfile only'
|
79
|
-
end
|
80
|
-
tl.info 'this message is logfile and console'
|
81
|
-
|
82
|
-
# and others like Logger's
|
83
|
-
tl.debug? # => true
|
84
|
-
tl.info?
|
85
|
-
tl.warn?
|
86
|
-
tl.error?
|
87
|
-
tl.fatal?
|
88
|
-
|
89
|
-
tl.level # => 0
|
90
|
-
tl.level = Logger::INFO
|
91
|
-
tl.debug 'this message is not logging'
|
92
|
-
|
93
|
-
tl.formatter # => nil or Proc
|
94
|
-
tl.formatter = proc {|severity, datetime, progname, message| "#{severity}:#{message}" }
|
95
|
-
```
|
96
|
-
|
97
|
-
|
98
|
-
## Development
|
99
|
-
|
100
|
-
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.
|
101
|
-
|
102
|
-
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).
|
103
|
-
|
104
|
-
|
105
|
-
## Contributing
|
106
|
-
|
107
|
-
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.
|
108
|
-
|
109
|
-
|
110
|
-
## License
|
111
|
-
|
112
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/tee_logger.svg)](http://badge.fury.io/rb/tee_logger)
|
2
|
+
[![Build Status](https://travis-ci.org/k-ta-yamada/tee_logger.svg)](https://travis-ci.org/k-ta-yamada/tee_logger)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/k-ta-yamada/tee_logger/badges/gpa.svg)](https://codeclimate.com/github/k-ta-yamada/tee_logger)
|
4
|
+
[![Test Coverage](https://codeclimate.com/github/k-ta-yamada/tee_logger/badges/coverage.svg)](https://codeclimate.com/github/k-ta-yamada/tee_logger/coverage)
|
5
|
+
|
6
|
+
> Sorry, I changed Usage from version 2.0.0
|
7
|
+
|
8
|
+
- [Rubygems.org](https://rubygems.org/gems/tee_logger)
|
9
|
+
- [GitHub](https://github.com/k-ta-yamada/tee_logger)
|
10
|
+
- [RubyDoc.info](http://www.rubydoc.info/gems/tee_logger)
|
11
|
+
|
12
|
+
# TeeLogger
|
13
|
+
|
14
|
+
logging to file and standard output.
|
15
|
+
require standard library only.
|
16
|
+
|
17
|
+
|
18
|
+
## Characteristic
|
19
|
+
|
20
|
+
- simple: use standard lib only.
|
21
|
+
- like Logger: see usage.
|
22
|
+
- enabled or disabled by switching the output of the console and the logfile.
|
23
|
+
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
Add this line to your application's Gemfile:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem 'tee_logger'
|
31
|
+
```
|
32
|
+
|
33
|
+
And then execute:
|
34
|
+
|
35
|
+
$ bundle
|
36
|
+
|
37
|
+
Or install it yourself as:
|
38
|
+
|
39
|
+
$ gem install tee_logger
|
40
|
+
|
41
|
+
|
42
|
+
## Usage
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'tee_logger'
|
46
|
+
|
47
|
+
# Logger.new like options(logdev, shift_age, shift_size)
|
48
|
+
# options default value is
|
49
|
+
# logdev = './tee_logger.log'
|
50
|
+
# shift_age = 0
|
51
|
+
# shift_size = 1_048_576
|
52
|
+
tl = TeeLogger.new
|
53
|
+
|
54
|
+
# let's logging
|
55
|
+
tl.debug 'hello'
|
56
|
+
tl.debug(:progname) { 'hello world' }
|
57
|
+
tl.progname = 'App'
|
58
|
+
tl.debug 'hello tee_logger'
|
59
|
+
|
60
|
+
# disable console output
|
61
|
+
tl.disable(:console)
|
62
|
+
tl.info 'this message is logfile only'
|
63
|
+
|
64
|
+
# enable console output
|
65
|
+
tl.enable(:console)
|
66
|
+
tl.info 'this message is logfile and console'
|
67
|
+
|
68
|
+
# disable logfile output
|
69
|
+
tl.disable(:logfile)
|
70
|
+
tl.info 'this message is consle only'
|
71
|
+
|
72
|
+
# enable logfile output
|
73
|
+
tl.enable(:logfile)
|
74
|
+
tl.info 'this message is logfile and console'
|
75
|
+
|
76
|
+
# disabe in block
|
77
|
+
tl.disable(:console) do
|
78
|
+
tl.info 'this message is logfile only'
|
79
|
+
end
|
80
|
+
tl.info 'this message is logfile and console'
|
81
|
+
|
82
|
+
# and others like Logger's
|
83
|
+
tl.debug? # => true
|
84
|
+
tl.info?
|
85
|
+
tl.warn?
|
86
|
+
tl.error?
|
87
|
+
tl.fatal?
|
88
|
+
|
89
|
+
tl.level # => 0
|
90
|
+
tl.level = Logger::INFO
|
91
|
+
tl.debug 'this message is not logging'
|
92
|
+
|
93
|
+
tl.formatter # => nil or Proc
|
94
|
+
tl.formatter = proc {|severity, datetime, progname, message| "#{severity}:#{message}" }
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
## Development
|
99
|
+
|
100
|
+
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.
|
101
|
+
|
102
|
+
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).
|
103
|
+
|
104
|
+
|
105
|
+
## Contributing
|
106
|
+
|
107
|
+
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.
|
108
|
+
|
109
|
+
|
110
|
+
## License
|
111
|
+
|
112
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
|
6
|
-
task default: :spec
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task default: :spec
|
data/lib/tee_logger/version.rb
CHANGED
data/lib/tee_logger.rb
CHANGED
@@ -18,28 +18,35 @@ module TeeLogger
|
|
18
18
|
# @see http://www.rubydoc.info/stdlib/logger/Logger Logger
|
19
19
|
class TeeLogger
|
20
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
|
+
|
21
40
|
# @!macro [attach] loglevel_check_methods
|
22
41
|
# @!method $1(name)
|
23
42
|
# @return [Boolean]
|
24
43
|
def define_loglevel_check_methods(name)
|
25
44
|
define_method(name) do
|
26
|
-
@logfile.send(name)
|
27
45
|
@console.send(name)
|
46
|
+
@logfile.send(name)
|
28
47
|
end
|
29
48
|
end
|
30
49
|
private :define_loglevel_check_methods
|
31
|
-
|
32
|
-
# @!macro [attach] logging_methods
|
33
|
-
# @!method $1(progname = nil, &block)
|
34
|
-
# logging $1 level message.
|
35
|
-
# @return true
|
36
|
-
def define_logging_methods(name)
|
37
|
-
define_method(name) do |progname = nil, &block|
|
38
|
-
@logfile.send(name, progname, &block)
|
39
|
-
@console.send(name, progname, &block)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
private :define_logging_methods
|
43
50
|
end
|
44
51
|
|
45
52
|
attr_reader :level, :progname, :formatter
|
@@ -49,8 +56,8 @@ module TeeLogger
|
|
49
56
|
# @param shift_size [Integer]
|
50
57
|
# @see Logger#initialize
|
51
58
|
def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
52
|
-
@logfile = Logger.new(logdev, shift_age, shift_size)
|
53
59
|
@console = Logger.new($stdout)
|
60
|
+
@logfile = Logger.new(logdev, shift_age, shift_size)
|
54
61
|
end
|
55
62
|
|
56
63
|
define_logging_methods :debug
|
@@ -67,48 +74,47 @@ module TeeLogger
|
|
67
74
|
|
68
75
|
# @param level [Integer]
|
69
76
|
def level=(level)
|
70
|
-
@logfile.level = level
|
71
|
-
@console.level = level
|
72
|
-
@level = level
|
77
|
+
@console.level = @logfile.level = @level = level
|
73
78
|
end
|
74
79
|
alias_method :sev_threshold, :level
|
75
80
|
alias_method :sev_threshold=, :level=
|
76
81
|
|
77
82
|
# @param name [String, Symbol]
|
78
83
|
def progname=(name = nil)
|
79
|
-
@logfile.progname = name
|
80
|
-
@console.progname = name
|
81
|
-
@progname = name
|
84
|
+
@console.progname = @logfile.progname = @progname = name
|
82
85
|
end
|
83
86
|
|
84
87
|
# @param formatter
|
85
88
|
def formatter=(formatter)
|
86
|
-
@logfile.formatter = formatter
|
87
|
-
@console.formatter = formatter
|
88
|
-
@formatter = formatter
|
89
|
+
@console.formatter = @logfile.formatter = @formatter = formatter
|
89
90
|
end
|
90
91
|
|
91
|
-
# @param
|
92
|
-
# @yield before
|
93
|
-
def disable(
|
92
|
+
# @param logdev_name [String, Symbol]
|
93
|
+
# @yield before logdev_name disable, after logdev_name enable.
|
94
|
+
def disable(logdev_name)
|
94
95
|
if block_given?
|
95
|
-
disable(
|
96
|
+
disable(logdev_name)
|
96
97
|
yield
|
97
|
-
enable(
|
98
|
+
enable(logdev_name)
|
98
99
|
else
|
99
|
-
|
100
|
+
logdev_instance(logdev_name).formatter = proc { |_, _, _, _| '' }
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
103
|
-
# @param
|
104
|
-
def enable(
|
105
|
-
|
104
|
+
# @param logdev_name [String, Symbol]
|
105
|
+
def enable(logdev_name)
|
106
|
+
logdev_instance(logdev_name).formatter = @formatter
|
106
107
|
end
|
107
108
|
|
108
109
|
private
|
109
110
|
|
110
|
-
def
|
111
|
-
|
111
|
+
def logging(name, progname, &block)
|
112
|
+
@console.send(name, progname, &block)
|
113
|
+
@logfile.send(name, progname, &block)
|
114
|
+
end
|
115
|
+
|
116
|
+
def logdev_instance(logdev_name)
|
117
|
+
instance_variable_get("@#{logdev_name}")
|
112
118
|
end
|
113
119
|
end
|
114
120
|
end
|
data/tee_logger.gemspec
CHANGED
@@ -1,38 +1,38 @@
|
|
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 =
|
14
|
-
'logging to file and standard output. require standard library only.'
|
15
|
-
|
16
|
-
spec.homepage = 'https://github.com/k-ta-yamada/tee_logger'
|
17
|
-
spec.license = 'MIT'
|
18
|
-
|
19
|
-
# rubocop:disable Metrics/LineLength
|
20
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
-
# rubocop:enable Metrics/LineLength
|
22
|
-
spec.bindir = 'exe'
|
23
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
-
spec.require_paths = ['lib']
|
25
|
-
|
26
|
-
spec.add_development_dependency 'bundler', '~> 1.10'
|
27
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
-
spec.add_development_dependency 'rspec'
|
29
|
-
spec.add_development_dependency 'fuubar'
|
30
|
-
|
31
|
-
spec.add_development_dependency 'pry'
|
32
|
-
spec.add_development_dependency 'pry-doc'
|
33
|
-
spec.add_development_dependency 'pry-theme'
|
34
|
-
spec.add_development_dependency 'rubocop'
|
35
|
-
|
36
|
-
spec.add_development_dependency 'capture_stdout'
|
37
|
-
spec.add_development_dependency 'fakefs'
|
38
|
-
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 =
|
14
|
+
'logging to file and standard output. require standard library only.'
|
15
|
+
|
16
|
+
spec.homepage = 'https://github.com/k-ta-yamada/tee_logger'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
# rubocop:disable Metrics/LineLength
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
# rubocop:enable Metrics/LineLength
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec'
|
29
|
+
spec.add_development_dependency 'fuubar'
|
30
|
+
|
31
|
+
spec.add_development_dependency 'pry'
|
32
|
+
spec.add_development_dependency 'pry-doc'
|
33
|
+
spec.add_development_dependency 'pry-theme'
|
34
|
+
spec.add_development_dependency 'rubocop'
|
35
|
+
|
36
|
+
spec.add_development_dependency 'capture_stdout'
|
37
|
+
spec.add_development_dependency 'fakefs'
|
38
|
+
end
|
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.6.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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|