tee_logger 2.4.1 → 2.5.0

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: e038d2637ea600e0ee63ecff7d2be02d8692658b
4
- data.tar.gz: 347e52f9ddd2ef5c76a4320951867d409062b368
3
+ metadata.gz: 769d6af48f3a6f679e38c6c411e3cd50f1975b33
4
+ data.tar.gz: 04cc26d406a0379be35fff2403fc5220c25664a5
5
5
  SHA512:
6
- metadata.gz: 553e57ad94ea5cff19078c08d4b414a1df6d045d720a10743c9c1dbb15961d55cc00e2ab49dff9d02079e3b7a2253961166ad3753f8f44c060716bd4314b732f
7
- data.tar.gz: 67aca467869d1aeef54ab6f225de2cb0a08d4d8e33307f48e75d75145b191ebfeb577d4b121df7b2b04452b796c2acbd3ffab1ae1ce3285c507f62188e356cdc
6
+ metadata.gz: deb859ba6ad1af5b756bb2c5786e79b64d4aa1f56e065f99363b3c31172ad625a53058437d7d51410dc9ca25bfceb4c2df6a6e6f4f49b1b13f46e553be397aa3
7
+ data.tar.gz: 34fbf45ece0f7598f71b6b3b2fd2ebe29799f9b04dcb10e9637477130b76e1d2f356feedc5846bf778218f347e687c554aa36dc1d7e2be181b3152f6a0ea9975
@@ -1,3 +1,8 @@
1
+ # v2.5.0
2
+ - level, progname and formatter were changed to instance variable
3
+ - refactoring: disabling and enabling
4
+ - rm ./lib/tee_logger/constants.rb. Constants move to ./lib/tee_logger.rb
5
+
1
6
  # v2.4.1
2
7
  - update README.md
3
8
  - and YARD comment
data/Gemfile CHANGED
@@ -2,4 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in tee_logger.gemspec
4
4
  gemspec
5
- gem "codeclimate-test-reporter", group: :test, require: nil
5
+ gem 'codeclimate-test-reporter', group: :test, require: nil
6
+ gem 'simplecov-console', group: :test, require: nil
@@ -1,9 +1,13 @@
1
1
  require 'tee_logger/version'
2
- require 'tee_logger/constants'
3
2
  require 'logger'
4
3
 
5
4
  # namespace
6
5
  module TeeLogger
6
+ # no param of filename, set this filename
7
+ DEFAULT_FILE = './tee_logger.log'
8
+ # Implements targets
9
+ LOGGING_METHODS = [:debug, :info, :warn, :error, :fatal].freeze
10
+
7
11
  # shortcut for TeeLogger::TeeLogger.new
8
12
  # @see TeeLogger
9
13
  def self.new(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
@@ -13,18 +17,7 @@ module TeeLogger
13
17
  # main
14
18
  # @see http://www.rubydoc.info/stdlib/logger/Logger Logger
15
19
  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
20
  class << self
26
- private
27
-
28
21
  # @!macro [attach] loglevel_check_methods
29
22
  # @!method $1(name)
30
23
  # @return [Boolean]
@@ -34,6 +27,7 @@ module TeeLogger
34
27
  @console.send(name)
35
28
  end
36
29
  end
30
+ private :define_loglevel_check_methods
37
31
 
38
32
  # @!macro [attach] logging_methods
39
33
  # @!method $1(progname = nil, &block)
@@ -45,13 +39,19 @@ module TeeLogger
45
39
  @console.send(name, progname, &block)
46
40
  end
47
41
  end
42
+ private :define_logging_methods
48
43
  end
49
44
 
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?
45
+ attr_reader :level, :progname, :formatter
46
+
47
+ # @param logdev [String]
48
+ # @param shift_age [Integer]
49
+ # @param shift_size [Integer]
50
+ # @see Logger#initialize
51
+ def initialize(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
52
+ @logfile = Logger.new(logdev, shift_age, shift_size)
53
+ @console = Logger.new($stdout)
54
+ end
55
55
 
56
56
  define_logging_methods :debug
57
57
  define_logging_methods :info
@@ -59,48 +59,35 @@ module TeeLogger
59
59
  define_logging_methods :error
60
60
  define_logging_methods :fatal
61
61
 
62
- # TODO: which value?
63
- # @return [Integer]
64
- def level
65
- @logfile.level
66
- @console.level
67
- end
62
+ define_loglevel_check_methods :debug?
63
+ define_loglevel_check_methods :info?
64
+ define_loglevel_check_methods :warn?
65
+ define_loglevel_check_methods :error?
66
+ define_loglevel_check_methods :fatal?
68
67
 
69
68
  # @param level [Integer]
70
69
  def level=(level)
71
70
  @logfile.level = level
72
71
  @console.level = level
72
+ @level = level
73
73
  end
74
- alias_method :sev_threshold, :level
74
+ alias_method :sev_threshold, :level
75
75
  alias_method :sev_threshold=, :level=
76
76
 
77
- # TODO: both values?
78
- # @return [String]
79
- def progname
80
- @logfile.progname
81
- @console.progname
82
- end
83
-
84
77
  # @param name [String, Symbol]
85
78
  def progname=(name = nil)
86
79
  @logfile.progname = name
87
80
  @console.progname = name
88
- end
89
-
90
- # TODO: both values?
91
- # @return [String]
92
- def formatter
93
- @logfile.formatter
94
- @console.formatter
81
+ @progname = name
95
82
  end
96
83
 
97
84
  # @param formatter
98
85
  def formatter=(formatter)
99
86
  @logfile.formatter = formatter
100
87
  @console.formatter = formatter
88
+ @formatter = formatter
101
89
  end
102
90
 
103
- # @todo Too miscellaneous
104
91
  # @param target [String, Symbol]
105
92
  # @yield before target disable, after target enable.
106
93
  def disable(target)
@@ -109,14 +96,19 @@ module TeeLogger
109
96
  yield
110
97
  enable(target)
111
98
  else
112
- instance_variable_get("@#{target}").formatter = proc { |_, _, _, _| '' }
99
+ target_instance(target).formatter = proc { |_, _, _, _| '' }
113
100
  end
114
101
  end
115
102
 
116
- # @todo Too miscellaneous
117
103
  # @param target [String, Symbol]
118
104
  def enable(target)
119
- instance_variable_get("@#{target}").formatter = Logger::Formatter.new
105
+ target_instance(target).formatter = @formatter
106
+ end
107
+
108
+ private
109
+
110
+ def target_instance(target)
111
+ instance_variable_get("@#{target}")
120
112
  end
121
113
  end
122
114
  end
@@ -1,5 +1,5 @@
1
1
  # namespace
2
2
  module TeeLogger
3
3
  # version number
4
- VERSION = '2.4.1'
4
+ VERSION = '2.5.0'
5
5
  end
@@ -16,7 +16,9 @@ Gem::Specification.new do |spec|
16
16
  spec.homepage = 'https://github.com/k-ta-yamada/tee_logger'
17
17
  spec.license = 'MIT'
18
18
 
19
+ # rubocop:disable Metrics/LineLength
19
20
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ # rubocop:enable Metrics/LineLength
20
22
  spec.bindir = 'exe'
21
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
24
  spec.require_paths = ['lib']
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.1
4
+ version: 2.5.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-10 00:00:00.000000000 Z
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -166,10 +166,7 @@ files:
166
166
  - LICENSE.txt
167
167
  - README.md
168
168
  - Rakefile
169
- - bin/console
170
- - bin/setup
171
169
  - lib/tee_logger.rb
172
- - lib/tee_logger/constants.rb
173
170
  - lib/tee_logger/version.rb
174
171
  - tee_logger.gemspec
175
172
  homepage: https://github.com/k-ta-yamada/tee_logger
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "tee_logger"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
@@ -1,10 +0,0 @@
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