tee_logger 2.4.0 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0ff6fc15c1c8e804ba3667f9d181483125639e7
4
- data.tar.gz: b7370c6fd53453ad75b82aac738fbe310fca0d5a
3
+ metadata.gz: e038d2637ea600e0ee63ecff7d2be02d8692658b
4
+ data.tar.gz: 347e52f9ddd2ef5c76a4320951867d409062b368
5
5
  SHA512:
6
- metadata.gz: 4b83206e8378f1e44920fa27419f07829dd00106a7e9b899eab201bfe11608ec8840038175e7e8629c91cbdc532b5a213ac6982a7e595a7dfb2078cb86abf71d
7
- data.tar.gz: b724b8b6e99e0213cb0aebb98e7b51ea1ef0398989f34563a232ef8f1badc0e0b77e79ff4bd9843ec947648169155c492fcb0c61616db0281968145b9d3f6532
6
+ metadata.gz: 553e57ad94ea5cff19078c08d4b414a1df6d045d720a10743c9c1dbb15961d55cc00e2ab49dff9d02079e3b7a2253961166ad3753f8f44c060716bd4314b732f
7
+ data.tar.gz: 67aca467869d1aeef54ab6f225de2cb0a08d4d8e33307f48e75d75145b191ebfeb577d4b121df7b2b04452b796c2acbd3ffab1ae1ce3285c507f62188e356cdc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v2.4.1
2
+ - update README.md
3
+ - and YARD comment
4
+
1
5
  # v2.4.0
2
6
  - TeeLogger#disable is allow block given
3
7
 
data/README.md CHANGED
@@ -1,106 +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' # => D, [2015-09-10T00:36:45.925312 #16227] DEBUG -- : hello
56
- tl.debug(:progname) { 'hello world' } # => D, [2015-09-10T00:37:31.940226 #16227] DEBUG -- progname: hello world
57
- tl.progname = 'App'
58
- tl.debug 'hello tee_logger' # => D, [2015-09-10T00:38:38.704274 #16227] DEBUG -- App: 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
- # and others like Logger's
77
- tl.debug? # => true
78
- tl.info? # => true
79
- tl.warn? # => true
80
- tl.error? # => true
81
- tl.fatal? # => true
82
-
83
- tl.level # => 0
84
- tl.level = Logger::INFO
85
- tl.debug 'this message is not logging'
86
-
87
- tl.formatter # => nil or Proc
88
- tl.formatter = proc {|severity, datetime, progname, message| "#{severity}:#{message}" }
89
- ```
90
-
91
-
92
- ## Development
93
-
94
- 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.
95
-
96
- 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).
97
-
98
-
99
- ## Contributing
100
-
101
- 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.
102
-
103
-
104
- ## License
105
-
106
- 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).
@@ -1,10 +1,10 @@
1
- require 'logger'
2
-
3
- # namespace
4
- module TeeLogger
5
- # no param of filename, set this filename
6
- DEFAULT_FILE = './tee_logger.log'
7
-
8
- # Implements targets
9
- LOGGING_METHODS = [:debug, :info, :warn, :error, :fatal].freeze
10
- end
1
+ require 'logger'
2
+
3
+ # namespace
4
+ module TeeLogger
5
+ # no param of filename, set this filename
6
+ DEFAULT_FILE = './tee_logger.log'
7
+
8
+ # Implements targets
9
+ LOGGING_METHODS = [:debug, :info, :warn, :error, :fatal].freeze
10
+ end
@@ -1,5 +1,5 @@
1
- # namespace
2
- module TeeLogger
3
- # version number
4
- VERSION = '2.4.0'
5
- end
1
+ # namespace
2
+ module TeeLogger
3
+ # version number
4
+ VERSION = '2.4.1'
5
+ end
data/lib/tee_logger.rb CHANGED
@@ -1,121 +1,122 @@
1
- require 'tee_logger/version'
2
- require 'tee_logger/constants'
3
- require 'logger'
4
-
5
- # namespace
6
- module TeeLogger
7
- # shortcut for TeeLogger::TeeLogger.new
8
- # @see TeeLogger
9
- def self.new(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
10
- TeeLogger.new(logdev, shift_age, shift_size)
11
- end
12
-
13
- # main
14
- # @see http://www.rubydoc.info/stdlib/logger/Logger Logger
15
- class TeeLogger
16
- # @param logdev String
17
- # @param shift_age Integer
18
- # @param shift_size Integer
19
- # @see Logger#initialize
20
- def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
21
- @logfile = Logger.new(logdev, shift_age, shift_size)
22
- @console = Logger.new($stdout)
23
- end
24
-
25
- class << self
26
- private
27
-
28
- # @!macro [attach] loglevel_check_methods
29
- # @!method $1(name)
30
- # @return [Boolean]
31
- def define_loglevel_check_methods(name)
32
- define_method(name) do
33
- @logfile.send(name)
34
- @console.send(name)
35
- end
36
- end
37
-
38
- # @!macro [attach] logging_methods
39
- # @!method $1(progname = nil, &block)
40
- # logging $1 level message.
41
- # @return true
42
- def define_logging_methods(name)
43
- define_method(name) do |progname = nil, &block|
44
- @logfile.send(name, progname, &block)
45
- @console.send(name, progname, &block)
46
- end
47
- end
48
- end
49
-
50
- define_loglevel_check_methods :debug?
51
- define_loglevel_check_methods :info?
52
- define_loglevel_check_methods :warn?
53
- define_loglevel_check_methods :error?
54
- define_loglevel_check_methods :fatal?
55
-
56
- define_logging_methods :debug
57
- define_logging_methods :info
58
- define_logging_methods :warn
59
- define_logging_methods :error
60
- define_logging_methods :fatal
61
-
62
- # TODO: which value?
63
- # @return [Integer]
64
- def level
65
- @logfile.level
66
- @console.level
67
- end
68
-
69
- # @param level [Integer]
70
- def level=(level)
71
- @logfile.level = level
72
- @console.level = level
73
- end
74
- alias_method :sev_threshold, :level
75
- alias_method :sev_threshold=, :level=
76
-
77
- # TODO: both values?
78
- # @return [String]
79
- def progname
80
- @logfile.progname
81
- @console.progname
82
- end
83
-
84
- # @param name [String, Symbol]
85
- def progname=(name = nil)
86
- @logfile.progname = name
87
- @console.progname = name
88
- end
89
-
90
- # TODO: both values?
91
- # @return [String]
92
- def formatter
93
- @logfile.formatter
94
- @console.formatter
95
- end
96
-
97
- # @param formatter
98
- def formatter=(formatter)
99
- @logfile.formatter = formatter
100
- @console.formatter = formatter
101
- end
102
-
103
- # @todo Too miscellaneous
104
- # @param target [String, Symbol]
105
- def disable(target)
106
- if block_given?
107
- disable(target)
108
- yield
109
- enable(target)
110
- else
111
- instance_variable_get("@#{target}").formatter = proc { |_, _, _, _| '' }
112
- end
113
- end
114
-
115
- # @todo Too miscellaneous
116
- # @param target [String, Symbol]
117
- def enable(target)
118
- instance_variable_get("@#{target}").formatter = Logger::Formatter.new
119
- end
120
- end
121
- end
1
+ require 'tee_logger/version'
2
+ require 'tee_logger/constants'
3
+ require 'logger'
4
+
5
+ # namespace
6
+ module TeeLogger
7
+ # shortcut for TeeLogger::TeeLogger.new
8
+ # @see TeeLogger
9
+ def self.new(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
10
+ TeeLogger.new(logdev, shift_age, shift_size)
11
+ end
12
+
13
+ # main
14
+ # @see http://www.rubydoc.info/stdlib/logger/Logger Logger
15
+ class TeeLogger
16
+ # @param logdev String
17
+ # @param shift_age Integer
18
+ # @param shift_size Integer
19
+ # @see Logger#initialize
20
+ def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
21
+ @logfile = Logger.new(logdev, shift_age, shift_size)
22
+ @console = Logger.new($stdout)
23
+ end
24
+
25
+ class << self
26
+ private
27
+
28
+ # @!macro [attach] loglevel_check_methods
29
+ # @!method $1(name)
30
+ # @return [Boolean]
31
+ def define_loglevel_check_methods(name)
32
+ define_method(name) do
33
+ @logfile.send(name)
34
+ @console.send(name)
35
+ end
36
+ end
37
+
38
+ # @!macro [attach] logging_methods
39
+ # @!method $1(progname = nil, &block)
40
+ # logging $1 level message.
41
+ # @return true
42
+ def define_logging_methods(name)
43
+ define_method(name) do |progname = nil, &block|
44
+ @logfile.send(name, progname, &block)
45
+ @console.send(name, progname, &block)
46
+ end
47
+ end
48
+ end
49
+
50
+ define_loglevel_check_methods :debug?
51
+ define_loglevel_check_methods :info?
52
+ define_loglevel_check_methods :warn?
53
+ define_loglevel_check_methods :error?
54
+ define_loglevel_check_methods :fatal?
55
+
56
+ define_logging_methods :debug
57
+ define_logging_methods :info
58
+ define_logging_methods :warn
59
+ define_logging_methods :error
60
+ define_logging_methods :fatal
61
+
62
+ # TODO: which value?
63
+ # @return [Integer]
64
+ def level
65
+ @logfile.level
66
+ @console.level
67
+ end
68
+
69
+ # @param level [Integer]
70
+ def level=(level)
71
+ @logfile.level = level
72
+ @console.level = level
73
+ end
74
+ alias_method :sev_threshold, :level
75
+ alias_method :sev_threshold=, :level=
76
+
77
+ # TODO: both values?
78
+ # @return [String]
79
+ def progname
80
+ @logfile.progname
81
+ @console.progname
82
+ end
83
+
84
+ # @param name [String, Symbol]
85
+ def progname=(name = nil)
86
+ @logfile.progname = name
87
+ @console.progname = name
88
+ end
89
+
90
+ # TODO: both values?
91
+ # @return [String]
92
+ def formatter
93
+ @logfile.formatter
94
+ @console.formatter
95
+ end
96
+
97
+ # @param formatter
98
+ def formatter=(formatter)
99
+ @logfile.formatter = formatter
100
+ @console.formatter = formatter
101
+ end
102
+
103
+ # @todo Too miscellaneous
104
+ # @param target [String, Symbol]
105
+ # @yield before target disable, after target enable.
106
+ def disable(target)
107
+ if block_given?
108
+ disable(target)
109
+ yield
110
+ enable(target)
111
+ else
112
+ instance_variable_get("@#{target}").formatter = proc { |_, _, _, _| '' }
113
+ end
114
+ end
115
+
116
+ # @todo Too miscellaneous
117
+ # @param target [String, Symbol]
118
+ def enable(target)
119
+ instance_variable_get("@#{target}").formatter = Logger::Formatter.new
120
+ end
121
+ end
122
+ end
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.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - k-ta-yamada