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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -1
- data/lib/tee_logger.rb +34 -42
- data/lib/tee_logger/version.rb +1 -1
- data/tee_logger.gemspec +2 -0
- metadata +2 -5
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/lib/tee_logger/constants.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 769d6af48f3a6f679e38c6c411e3cd50f1975b33
|
4
|
+
data.tar.gz: 04cc26d406a0379be35fff2403fc5220c25664a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deb859ba6ad1af5b756bb2c5786e79b64d4aa1f56e065f99363b3c31172ad625a53058437d7d51410dc9ca25bfceb4c2df6a6e6f4f49b1b13f46e553be397aa3
|
7
|
+
data.tar.gz: 34fbf45ece0f7598f71b6b3b2fd2ebe29799f9b04dcb10e9637477130b76e1d2f356feedc5846bf778218f347e687c554aa36dc1d7e2be181b3152f6a0ea9975
|
data/CHANGELOG.md
CHANGED
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
|
5
|
+
gem 'codeclimate-test-reporter', group: :test, require: nil
|
6
|
+
gem 'simplecov-console', group: :test, require: nil
|
data/lib/tee_logger.rb
CHANGED
@@ -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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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,
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/tee_logger/version.rb
CHANGED
data/tee_logger.gemspec
CHANGED
@@ -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
|
+
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-
|
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
|
data/bin/console
DELETED
@@ -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
data/lib/tee_logger/constants.rb
DELETED