tee_logger 2.7.0 → 3.0.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 -57
- data/.rspec +2 -2
- data/.travis.yml +10 -10
- data/CHANGELOG.md +59 -53
- data/CODE_OF_CONDUCT.md +13 -13
- data/Gemfile +6 -6
- data/LICENSE.txt +21 -21
- data/README.md +145 -130
- data/Rakefile +4 -4
- data/lib/tee_logger.rb +132 -127
- data/lib/tee_logger/utils.rb +64 -0
- data/lib/tee_logger/version.rb +5 -5
- data/tee_logger.gemspec +39 -39
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fac48b2aa959b362ac7fa364c0a343a2f1588616
|
4
|
+
data.tar.gz: d14d1e2b0458879b5ddcbd11ae59a9514d29c2e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61e4ff27817c8717f338f38a01500c08041a32dbb0243d40c1dc2211be28b4f8638f38b692c9cd3d9ee0747129b1b8b2d59950b1522afebf24b887e0c042fe40
|
7
|
+
data.tar.gz: fda1d7ffb55beeecc1bca0241005a40d59adabdc92e1116dcc3939465e1f8959d89ab8ea695dfcde102c53183bcda096ba97d0806ddf3ab0f63df1614fcdce16
|
data/.gitignore
CHANGED
@@ -1,57 +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
|
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
|
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/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
--color
|
2
|
-
--format documentation
|
1
|
+
--color
|
2
|
+
--format documentation
|
data/.travis.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
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
|
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=
|
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
|
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,53 +1,59 @@
|
|
1
|
-
#
|
2
|
-
-
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
# v2.
|
8
|
-
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- and
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
-
|
21
|
-
|
22
|
-
# v2.
|
23
|
-
-
|
24
|
-
|
25
|
-
|
26
|
-
-
|
27
|
-
|
28
|
-
# v2.
|
29
|
-
-
|
30
|
-
|
31
|
-
|
32
|
-
-
|
33
|
-
|
34
|
-
|
35
|
-
-
|
36
|
-
|
37
|
-
# v2.1.
|
38
|
-
-
|
39
|
-
|
40
|
-
|
41
|
-
-
|
42
|
-
|
43
|
-
# v2.0
|
44
|
-
-
|
45
|
-
|
46
|
-
# v2.0.
|
47
|
-
-
|
48
|
-
|
49
|
-
#
|
50
|
-
- bugfix
|
51
|
-
|
52
|
-
#
|
53
|
-
-
|
1
|
+
# v3.0.0
|
2
|
+
- [issue #4](https://github.com/k-ta-yamada/tee_logger/issues/4)
|
3
|
+
logging method's parametrer disabling_target change to enabling_targe
|
4
|
+
- [issue #5](https://github.com/k-ta-yamada/tee_logger/issues/5)
|
5
|
+
log message indentation
|
6
|
+
|
7
|
+
# v2.7.0
|
8
|
+
- add datetime_format, datetime_format=
|
9
|
+
|
10
|
+
# v2.6.0
|
11
|
+
- disabling option add to logging_methods
|
12
|
+
|
13
|
+
# v2.5.0
|
14
|
+
- level, progname and formatter were changed to instance variable
|
15
|
+
- refactoring: disabling and enabling
|
16
|
+
- rm ./lib/tee_logger/constants.rb. Constants move to ./lib/tee_logger.rb
|
17
|
+
|
18
|
+
# v2.4.1
|
19
|
+
- update README.md
|
20
|
+
- and YARD comment
|
21
|
+
|
22
|
+
# v2.4.0
|
23
|
+
- TeeLogger#disable is allow block given
|
24
|
+
|
25
|
+
# v2.3.1
|
26
|
+
- refactoring TeeLogger#disable
|
27
|
+
|
28
|
+
# v2.3.0
|
29
|
+
- remove TeeLogger.attr_reader
|
30
|
+
- and rename instance variable: @logger => @logfile
|
31
|
+
- implementation `#level` and `level=`
|
32
|
+
- implementation `#formatter` and `formatter=`
|
33
|
+
|
34
|
+
# v2.2.0
|
35
|
+
- disabling and enabling
|
36
|
+
|
37
|
+
# v2.1.1
|
38
|
+
- refactoring of test case
|
39
|
+
- Introduced capture_stdout
|
40
|
+
- Introduced FakeFS
|
41
|
+
- Change logdev of Console for Logger from STDOUT to $ stdout
|
42
|
+
|
43
|
+
# v2.1.0
|
44
|
+
- Integrate TeeLogger::Base class to TeeLogger::TeeLogger class
|
45
|
+
|
46
|
+
# v2.0.2
|
47
|
+
- bugfix
|
48
|
+
|
49
|
+
# v2.0.1
|
50
|
+
- bugfix
|
51
|
+
|
52
|
+
# v2.0.0
|
53
|
+
- Change to Class from Module
|
54
|
+
|
55
|
+
# v1.1.0
|
56
|
+
- bugfix
|
57
|
+
|
58
|
+
# v1.0.0
|
59
|
+
- first
|
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,130 +1,145 @@
|
|
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
|
7
|
-
|
8
|
-
|
9
|
-
- [
|
10
|
-
- [
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
-
|
22
|
-
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
```
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
#
|
55
|
-
|
56
|
-
|
57
|
-
tl
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
tl.
|
62
|
-
tl.
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
tl.info 'this message is logfile
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
#
|
73
|
-
tl.
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
tl.
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
tl.
|
82
|
-
|
83
|
-
|
84
|
-
tl.
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
tl.
|
89
|
-
tl.
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
tl.
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
tl.
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
##
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
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. In from version 2 to version 3, changed usage.
|
7
|
+
> see also [CHANGELOG.md](/CHANGELOG.md#v300).
|
8
|
+
|
9
|
+
- [Rubygems.org](https://rubygems.org/gems/tee_logger)
|
10
|
+
- [GitHub](https://github.com/k-ta-yamada/tee_logger)
|
11
|
+
- [RubyDoc.info](http://www.rubydoc.info/gems/tee_logger)
|
12
|
+
|
13
|
+
# TeeLogger
|
14
|
+
|
15
|
+
logging to file and standard output.
|
16
|
+
require standard library only.
|
17
|
+
|
18
|
+
|
19
|
+
## Characteristic
|
20
|
+
|
21
|
+
- use standard lib only.
|
22
|
+
- like Logger: see usage.
|
23
|
+
- enabled or disabled by switching the output of the console and the logfile.
|
24
|
+
|
25
|
+
|
26
|
+
## Installation
|
27
|
+
|
28
|
+
Add this line to your application's Gemfile:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
gem 'tee_logger'
|
32
|
+
```
|
33
|
+
|
34
|
+
And then execute:
|
35
|
+
|
36
|
+
```
|
37
|
+
$ bundle
|
38
|
+
```
|
39
|
+
|
40
|
+
Or install it yourself as:
|
41
|
+
|
42
|
+
```
|
43
|
+
$ gem install tee_logger
|
44
|
+
```
|
45
|
+
|
46
|
+
|
47
|
+
## Usage
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
require 'tee_logger'
|
51
|
+
|
52
|
+
# Logger.new like options(logdev, shift_age, shift_size)
|
53
|
+
# options default value is
|
54
|
+
# logdev = './tee_logger.log'
|
55
|
+
# shift_age = 0
|
56
|
+
# shift_size = 1_048_576
|
57
|
+
tl = TeeLogger.new
|
58
|
+
|
59
|
+
# let's logging
|
60
|
+
tl.debug 'hello'
|
61
|
+
tl.debug(:progname) { 'hello world' }
|
62
|
+
tl.progname = 'App'
|
63
|
+
tl.debug 'hello tee_logger'
|
64
|
+
|
65
|
+
# enable only when specified
|
66
|
+
tl.info 'this message is console and logfile'
|
67
|
+
tl.info 'this message is console only', :console
|
68
|
+
tl.info 'this message is logfile only', :logfile
|
69
|
+
|
70
|
+
# log meassage indent
|
71
|
+
tl.info 'hello' # => 'hello'
|
72
|
+
tl.info 'hello', 0 # => 'hello'
|
73
|
+
tl.info 'hello', 2 # => ' hello'
|
74
|
+
|
75
|
+
# enabling and indent
|
76
|
+
tl.info 'this message is console only', 2, :console
|
77
|
+
tl.info 'this message is console only', :console, 2
|
78
|
+
|
79
|
+
# disable console output
|
80
|
+
tl.disable(:console)
|
81
|
+
tl.info 'this message is logfile only'
|
82
|
+
|
83
|
+
# enable console output
|
84
|
+
tl.enable(:console)
|
85
|
+
tl.info 'this message is logfile and console'
|
86
|
+
|
87
|
+
# disable logfile output
|
88
|
+
tl.disable(:logfile)
|
89
|
+
tl.info 'this message is consle only'
|
90
|
+
|
91
|
+
# enable logfile output
|
92
|
+
tl.enable(:logfile)
|
93
|
+
tl.info 'this message is logfile and console'
|
94
|
+
|
95
|
+
# disabe in block
|
96
|
+
tl.disable(:console) do
|
97
|
+
tl.info 'this message is logfile only'
|
98
|
+
end
|
99
|
+
tl.info 'this message is logfile and console'
|
100
|
+
|
101
|
+
# and others like Logger's
|
102
|
+
tl.debug? # => true
|
103
|
+
tl.info? # => true
|
104
|
+
tl.warn? # => true
|
105
|
+
tl.error? # => true
|
106
|
+
tl.fatal? # => true
|
107
|
+
|
108
|
+
tl.level # => 0
|
109
|
+
tl.level = Logger::INFO
|
110
|
+
tl.debug 'this message is not logging'
|
111
|
+
|
112
|
+
tl.formatter # => nil or Proc
|
113
|
+
tl.formatter = proc { |severity, datetime, progname, message| "#{severity}:#{message}" }
|
114
|
+
|
115
|
+
tl.datetime_format # => nil or Proc
|
116
|
+
tl.datetime_format = '%Y%m%d %H%M%S '
|
117
|
+
```
|
118
|
+
|
119
|
+
|
120
|
+
## Development
|
121
|
+
|
122
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
123
|
+
Then, run `rake rspec` to run the tests.
|
124
|
+
You can also run `budle exec pry -r ./lib/tee_logger` for an interactive prompt
|
125
|
+
that will allow you to experiment.
|
126
|
+
|
127
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
128
|
+
To release a new version, update the version number in `version.rb`,
|
129
|
+
and then run `bundle exec rake release`,
|
130
|
+
which will create a git tag for the version,
|
131
|
+
push git commits and tags,
|
132
|
+
and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
133
|
+
|
134
|
+
|
135
|
+
## Contributing
|
136
|
+
|
137
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/k-ta-yamada/tee_logger.
|
138
|
+
This project is intended to be a safe,
|
139
|
+
welcoming space for collaboration,
|
140
|
+
and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
141
|
+
|
142
|
+
|
143
|
+
## License
|
144
|
+
|
145
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
RSpec::Core::RakeTask.new(:spec)
|
4
|
-
task default: :spec
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
RSpec::Core::RakeTask.new(:spec)
|
4
|
+
task default: :spec
|
data/lib/tee_logger.rb
CHANGED
@@ -1,127 +1,132 @@
|
|
1
|
-
require 'tee_logger/
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
# @param
|
26
|
-
# @param
|
27
|
-
# @
|
28
|
-
# @
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
# @param
|
83
|
-
def
|
84
|
-
@console.
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
# @param
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
1
|
+
require 'tee_logger/utils'
|
2
|
+
require 'tee_logger/version'
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
# namespace
|
6
|
+
module TeeLogger
|
7
|
+
# no param of filename, set this filename
|
8
|
+
DEFAULT_FILE = './tee_logger.log'
|
9
|
+
# Implements targets
|
10
|
+
LOGGING_METHODS = [:debug, :info, :warn, :error, :fatal].freeze
|
11
|
+
|
12
|
+
# shortcut for TeeLogger::TeeLogger.new
|
13
|
+
# @see TeeLogger
|
14
|
+
def self.new(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
15
|
+
TeeLogger.new(logdev, shift_age, shift_size)
|
16
|
+
end
|
17
|
+
|
18
|
+
# main
|
19
|
+
# @see http://www.rubydoc.info/stdlib/logger/Logger Logger
|
20
|
+
class TeeLogger
|
21
|
+
class << self
|
22
|
+
# @!macro [attach] logging_methods
|
23
|
+
# @!method $1(progname = nil, disabling_target = nil, &block)
|
24
|
+
# logging $1 level message.
|
25
|
+
# @param progname see also Logger
|
26
|
+
# @param disabling_target (Symbol) valid values => [:console, :logfile]
|
27
|
+
# @param &block see also Logger
|
28
|
+
# @return true
|
29
|
+
# @see Logger
|
30
|
+
def define_logging_methods(name)
|
31
|
+
define_method(name) do |progname = nil, *options, &block|
|
32
|
+
opts = parse_to_hash_from(options)
|
33
|
+
|
34
|
+
disabling_target = reverse_target(opts[:enabling_target])
|
35
|
+
progname, block = indentation(progname, block, opts[:indent_level])
|
36
|
+
|
37
|
+
if disabling_target.nil?
|
38
|
+
logging(name, progname, &block)
|
39
|
+
else
|
40
|
+
disable(disabling_target) { logging(name, progname, &block) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
private :define_logging_methods
|
45
|
+
|
46
|
+
# @!macro [attach] loglevel_check_methods
|
47
|
+
# @!method $1(name)
|
48
|
+
# @return [Boolean]
|
49
|
+
def define_loglevel_check_methods(name)
|
50
|
+
define_method(name) do
|
51
|
+
@console.send(name)
|
52
|
+
@logfile.send(name)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
private :define_loglevel_check_methods
|
56
|
+
end
|
57
|
+
|
58
|
+
include Utils
|
59
|
+
attr_reader :level, :progname, :formatter, :datetime_format
|
60
|
+
|
61
|
+
# @param logdev [String]
|
62
|
+
# @param shift_age [Integer]
|
63
|
+
# @param shift_size [Integer]
|
64
|
+
# @see Logger#initialize
|
65
|
+
def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
|
66
|
+
@console = Logger.new($stdout)
|
67
|
+
@logfile = Logger.new(logdev, shift_age, shift_size)
|
68
|
+
end
|
69
|
+
|
70
|
+
define_logging_methods :debug
|
71
|
+
define_logging_methods :info
|
72
|
+
define_logging_methods :warn
|
73
|
+
define_logging_methods :error
|
74
|
+
define_logging_methods :fatal
|
75
|
+
|
76
|
+
define_loglevel_check_methods :debug?
|
77
|
+
define_loglevel_check_methods :info?
|
78
|
+
define_loglevel_check_methods :warn?
|
79
|
+
define_loglevel_check_methods :error?
|
80
|
+
define_loglevel_check_methods :fatal?
|
81
|
+
|
82
|
+
# @param level [Integer]
|
83
|
+
def level=(level)
|
84
|
+
@console.level = @logfile.level = @level = level
|
85
|
+
end
|
86
|
+
alias_method :sev_threshold, :level
|
87
|
+
alias_method :sev_threshold=, :level=
|
88
|
+
|
89
|
+
# @param name [String, Symbol]
|
90
|
+
def progname=(name = nil)
|
91
|
+
@console.progname = @logfile.progname = @progname = name
|
92
|
+
end
|
93
|
+
|
94
|
+
# @param formatter
|
95
|
+
def formatter=(formatter)
|
96
|
+
@console.formatter = @logfile.formatter = @formatter = formatter
|
97
|
+
end
|
98
|
+
|
99
|
+
# @param formatter
|
100
|
+
def datetime_format=(format)
|
101
|
+
@console.datetime_format =
|
102
|
+
@logfile.datetime_format =
|
103
|
+
@datetime_format = format
|
104
|
+
end
|
105
|
+
|
106
|
+
# @param logdev_name [String, Symbol]
|
107
|
+
# @yield before logdev_name disable, after logdev_name enable.
|
108
|
+
def disable(logdev_name)
|
109
|
+
correct_name?(logdev_name)
|
110
|
+
if block_given?
|
111
|
+
disable(logdev_name)
|
112
|
+
yield
|
113
|
+
enable(logdev_name)
|
114
|
+
else
|
115
|
+
logdev_instance(logdev_name).formatter = proc { |_, _, _, _| '' }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# @param logdev_name [String, Symbol]
|
120
|
+
def enable(logdev_name)
|
121
|
+
correct_name?(logdev_name)
|
122
|
+
logdev_instance(logdev_name).formatter = @formatter
|
123
|
+
end
|
124
|
+
|
125
|
+
private
|
126
|
+
|
127
|
+
def logging(name, progname, &block)
|
128
|
+
@console.send(name, progname, &block)
|
129
|
+
@logfile.send(name, progname, &block)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# namespace
|
2
|
+
module TeeLogger
|
3
|
+
# util
|
4
|
+
module Utils
|
5
|
+
class IncorrectNameError < StandardError; end
|
6
|
+
|
7
|
+
# defined log devices names
|
8
|
+
LOGDEVS = %i(console logfile)
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def parse_to_hash_from(options)
|
13
|
+
result = { enabling_target: nil, indent_level: 0 }
|
14
|
+
options.each_with_object(result) do |val, obj|
|
15
|
+
if val.is_a?(Symbol)
|
16
|
+
correct_name?(val)
|
17
|
+
obj[:enabling_target] = LOGDEVS.include?(val) ? val : nil
|
18
|
+
elsif val.is_a?(Fixnum)
|
19
|
+
obj[:indent_level] = val
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def reverse_target(logdev_name)
|
25
|
+
case logdev_name
|
26
|
+
when :console then :logfile
|
27
|
+
when :logfile then :console
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def indentation(progname, block, indent_level)
|
32
|
+
if block.nil?
|
33
|
+
progname = "#{' ' * indent_level}#{formatting(progname)}"
|
34
|
+
else
|
35
|
+
result = block.call
|
36
|
+
block = proc { "#{' ' * indent_level}#{formatting(result)}" }
|
37
|
+
end
|
38
|
+
[progname, block]
|
39
|
+
end
|
40
|
+
|
41
|
+
def formatting(val)
|
42
|
+
if val.is_a?(Symbol)
|
43
|
+
":#{val}"
|
44
|
+
elsif val.nil?
|
45
|
+
'nil'
|
46
|
+
else
|
47
|
+
val
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def correct_name?(logdev_name)
|
52
|
+
if LOGDEVS.include?(logdev_name)
|
53
|
+
true
|
54
|
+
else
|
55
|
+
fail IncorrectNameError,
|
56
|
+
"logdev_name=[:#{logdev_name}]:logdev_name is :console or :logfile"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def logdev_instance(logdev_name)
|
61
|
+
instance_variable_get("@#{logdev_name}")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/tee_logger/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# namespace
|
2
|
-
module TeeLogger
|
3
|
-
# version number
|
4
|
-
VERSION = '
|
5
|
-
end
|
1
|
+
# namespace
|
2
|
+
module TeeLogger
|
3
|
+
# version number
|
4
|
+
VERSION = '3.0.0'
|
5
|
+
end
|
data/tee_logger.gemspec
CHANGED
@@ -1,39 +1,39 @@
|
|
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
|
-
spec.add_development_dependency 'parallel'
|
39
|
-
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
|
+
spec.add_development_dependency 'parallel'
|
39
|
+
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:
|
4
|
+
version: 3.0.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-
|
11
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- README.md
|
182
182
|
- Rakefile
|
183
183
|
- lib/tee_logger.rb
|
184
|
+
- lib/tee_logger/utils.rb
|
184
185
|
- lib/tee_logger/version.rb
|
185
186
|
- tee_logger.gemspec
|
186
187
|
homepage: https://github.com/k-ta-yamada/tee_logger
|