loggerx 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3d670b6073866d77bce705fbfee4766ec35a56efa25915c1640bacc6752ef76
4
- data.tar.gz: 1ccd5529fb4a87b383e500cad777d7c58441b803343753ea93c43f34c940e42d
3
+ metadata.gz: 3fd826254376e64dc953e21e9ba92bc7ae0fc1a9f53c293b19ed093616acce29
4
+ data.tar.gz: 81d5fcb3dc14a34df39d491a88604a163041548baffa1f9d829645d8f2f95f95
5
5
  SHA512:
6
- metadata.gz: 1727d5e45c7910f3fe631b52329d0fadcb6e9d05eed54ed1731552dcf46c3ba257ade18e53bb51ae9a9bbf5477f69fe16bbff6067e0f495412b1b42c289516d4
7
- data.tar.gz: 7fe553f310c18547b0274e6f45f2a06b8bedd69df01c2eb06700c62e7fa2434312b2f5dfee9a2f76df3600670fd1f0956a829aba4905b264d7e31700f5bf5b30
6
+ metadata.gz: c9af8636e84e6469b63737a4b884406a3288b94d1ed60538f170272ac558515cd867d1f05317ad4d720dd1a3b41d2f88d2534cf3c3ebc731c55d70f2ceee0886
7
+ data.tar.gz: c5f6b9998cde8d0cc122786b20a7287120e07a215ac3182c24e116efb04cad518018ee4b0fc49db50bd8253e6f20d9b5bbaef88175022fd04588fadc89991889
data/.rubocop.yml CHANGED
@@ -8,29 +8,80 @@ AllCops:
8
8
  NewCops: enable
9
9
  TargetRubyVersion: 3.1
10
10
 
11
- Style/StringLiterals:
12
- Enabled: true
13
- EnforcedStyle: double_quotes
11
+ DisplayCopNames: true
12
+ StyleGuideBaseURL: https://github.com/fortissimo1997/ruby-style-guide/blob/japanese/README.ja.md
13
+ # 結果のsuggest部分を非表示にする
14
+ SuggestExtensions: false
15
+ # rubocopの対象外ファイル
16
+ Exclude:
17
+ - "Gemfile"
18
+ - "bin/**/*"
19
+ - "db/**/*"
20
+ - "log/**/*"
21
+ - "tmp/**/*"
22
+ - "vendor/**/*"
23
+ - "lib/tasks/auto_annotate_models.rake"
24
+ - "config/environments/*"
25
+ - "config/puma.rb"
26
+ - "root/**/*"
27
+ - "test_data/**/*"
28
+ - "test_data_y/**/*"
29
+ - "test_other/**/*"
30
+ - "test_output/**/*"
31
+ - "tmp/**/*"
32
+ - "pkg/**/*"
33
+ - "docs/**/*"
14
34
 
15
- Style/StringLiteralsInInterpolation:
16
- Enabled: true
17
- EnforcedStyle: double_quotes
18
35
 
19
- Layout/LineLength:
20
- Max: 120
36
+ Layout:
37
+ # メソッド名をcamelCase に設定します
38
+ MethodName:
39
+ # EnforcedStyle: camelCase
40
+ EnforcedStyle: snake_case
41
+ # 一行に 120 文字まで書いても OK とする
42
+ LineLength:
43
+ Max: 120
21
44
 
45
+ Style:
46
+ StringLiterals:
47
+ Enabled: true
48
+ EnforcedStyle: double_quotes
49
+
50
+ StringLiteralsInInterpolation:
51
+ Enabled: true
52
+ EnforcedStyle: double_quotes
22
53
  #追加
23
- Style/FrozenStringLiteralComment:
24
- Enabled: false
25
-
26
- Style/Documentation:
27
- Enabled: false
28
- Style/ClassAndModuleChildren:
29
- Enabled: false
30
- Style/GuardClause:
31
- Enabled: false
32
- Style/IfUnlessModifier:
33
- Enabled: false
34
-
35
- Metrics/ClassLength:
36
- Enabled: false
54
+ rozenStringLiteralComment:
55
+ Enabled: false
56
+ ClassAndModuleChildren:
57
+ Enabled: false
58
+ GuardClause:
59
+ Enabled: false
60
+ IfUnlessModifier:
61
+ Enabled: false
62
+ # 日本語のコメントを OK とする
63
+ AsciiComments:
64
+ Enabled: false
65
+ BlockComments:
66
+ Enabled: false
67
+
68
+ # class documentation commentのアラートを出さない
69
+ Documentation:
70
+ Enabled: false
71
+ IfWithBooleanLiteralBranches:
72
+ Enabled: false
73
+
74
+ Naming:
75
+ RescuedExceptionsVariableName:
76
+ PreferredName: exc
77
+
78
+ Lint:
79
+ DuplicateRegexpCharacterClassElement:
80
+ Enabled: false
81
+
82
+
83
+ Metrics:
84
+ ClassLength:
85
+ # Enabled: false
86
+ Max: 440 # クラスの最大行数をここで設定
87
+
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
@@ -2,15 +2,15 @@
2
2
 
3
3
  module Loggerx
4
4
  class Loggerx
5
- require "logger"
6
- require "fileutils"
7
- require "stringio"
5
+ require 'logger'
6
+ require 'fileutils'
7
+ require 'stringio'
8
8
 
9
9
  LOG_FILENAME_BASE = "#{Time.now.strftime("%Y%m%d-%H%M%S")}.log".freeze
10
10
  @log_file = nil
11
11
  @log_stdout = nil
12
12
  @stdout_backup = $stdout
13
- @stringio = StringIO.new(+"", "w+")
13
+ @stringio = StringIO.new(+'', 'w+')
14
14
 
15
15
  attr_reader :error_count
16
16
 
@@ -38,14 +38,9 @@ module Loggerx
38
38
  fname = nil if fname == false
39
39
  fname = prefix + LOG_FILENAME_BASE if fname == :default
40
40
  @log_file = setup_logger_file(log_dir, fname) if fname
41
-
42
- obj = proc do |_, _, _, msg|
43
- "#{msg}\n"
44
- end
45
41
  # register_log_format(obj)
46
- formatter = obj
47
42
  # register_log_level(level_hs[level])
48
- level = level_hs[level]
43
+ level_hs[level]
49
44
  end
50
45
 
51
46
  def formatter
@@ -81,7 +76,6 @@ module Loggerx
81
76
 
82
77
  def setup_logger_file(log_dir, fname)
83
78
  filepath = Pathname.new(log_dir).join(fname)
84
- log_file = nil
85
79
  begin
86
80
  log ||= ActiveSupport::TaggedLogging.new(filepath)
87
81
  rescue Errno::EACCES
@@ -116,7 +110,7 @@ module Loggerx
116
110
  def to_string(value)
117
111
  if value.instance_of?(Array)
118
112
  @stdout_backup ||= $stdout
119
- @stringio ||= StringIO.new(+"", "w+")
113
+ @stringio ||= StringIO.new(+'', 'w+')
120
114
  $stdout = @stringio
121
115
  $stdout = @stdout_backup
122
116
  @stringio.rewind
@@ -150,7 +144,6 @@ module Loggerx
150
144
 
151
145
  def debug(value)
152
146
  str = to_string(value)
153
- # p str
154
147
  @log_file&.debug(str)
155
148
  @log_stdout&.debug(str)
156
149
  true
@@ -188,39 +181,39 @@ module Loggerx
188
181
  end
189
182
 
190
183
  def hash_to_args(hash)
191
- prefix = hash["prefix"]
192
- log_dir_pn = Pathname.new(hash["log_dir"])
184
+ prefix = hash['prefix']
185
+ log_dir_pn = Pathname.new(hash['log_dir'])
193
186
 
194
- stdout_flag_str = hash["stdout_flag"]
187
+ stdout_flag_str = hash['stdout_flag']
195
188
  stdout_flag = if stdout_flag_str.instance_of?(String)
196
- case stdout_flag_str
197
- when "true"
198
- true
199
- else
200
- false
201
- end
202
- else
203
- stdout_flag_str
204
- end
205
-
206
- fname_str = hash["fname"]
189
+ case stdout_flag_str
190
+ when 'true'
191
+ true
192
+ else
193
+ false
194
+ end
195
+ else
196
+ stdout_flag_str
197
+ end
198
+
199
+ fname_str = hash['fname']
207
200
  fname = case fname_str
208
- when "default"
209
- fname_str.to_sym
210
- when "false"
211
- false
212
- else
213
- fname_str
214
- end
201
+ when 'default'
202
+ fname_str.to_sym
203
+ when 'false'
204
+ false
205
+ else
206
+ fname_str
207
+ end
215
208
 
216
- level = hash["level"].to_sym
209
+ level = hash['level'].to_sym
217
210
 
218
211
  [prefix, fname, log_dir_pn, stdout_flag, level]
219
212
  end
220
213
 
221
214
  def create_by_hash(hash)
222
215
  prefix, fname, log_dir_pn, stdout_flag, level = hash_to_args(hash)
223
- new(prefix, fname, log_dir_pn, stdout_flag, level)
216
+ Loggerx.new(prefix, fname, log_dir_pn, stdout_flag, level)
224
217
  end
225
218
 
226
219
  def init_by_hash(hash)
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "pathname"
3
+ require 'pathname'
4
4
 
5
5
  module Loggerx
6
6
  class Loggerxcm0
7
- require "logger"
8
- require "fileutils"
9
- require "stringio"
7
+ require 'logger'
8
+ require 'fileutils'
9
+ require 'stringio'
10
10
 
11
11
  LOG_FILENAME_BASE = "#{Time.now.strftime("%Y%m%d-%H%M%S")}.log".freeze
12
12
  @log_file = nil
13
13
  @log_stdout = nil
14
14
  @stdout_backup = $stdout
15
- @stringio = StringIO.new(+"", "w+")
15
+ @stringio = StringIO.new(+'', 'w+')
16
16
  # @limit_of_num_of_files ||= 3
17
17
 
18
18
  class << self
@@ -73,8 +73,8 @@ module Loggerx
73
73
  if log_file.nil?
74
74
  begin
75
75
  log_file = Logger.new(filepath)
76
- rescue Errno::EACCES
77
- @error_count += 1
76
+ # rescue Errno::EACCES
77
+ # @error_count += 1
78
78
  rescue StandardError
79
79
  @error_count += 1
80
80
  end
@@ -98,7 +98,7 @@ module Loggerx
98
98
  def to_string(value)
99
99
  if value.instance_of?(Array)
100
100
  @stdout_backup ||= $stdout
101
- @stringio ||= StringIO.new(+"", "w+")
101
+ @stringio ||= StringIO.new(+'', 'w+')
102
102
  $stdout = @stringio
103
103
  $stdout = @stdout_backup
104
104
  @stringio.rewind
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Loggerx
4
- VERSION = "0.3.0"
4
+ VERSION = '0.3.1'
5
5
  end
data/lib/loggerx.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "loggerx/version"
4
- require_relative "loggerx/loggerx"
5
- require_relative "loggerx/loggerxcm"
3
+ require_relative 'loggerx/version'
4
+ require_relative 'loggerx/loggerx'
5
+ require_relative 'loggerx/loggerxcm'
6
6
 
7
7
  module Loggerx
8
8
  class Error < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggerx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ykominami