lumberaxe 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9f5c1078c58ccacfe207db7fb1ad45fd544c235efcbf510d44ccda8e2a156aca
4
+ data.tar.gz: f701378e011e2488500621c02cee6329ff9d98483dc09990f5379c430fd3e12f
5
+ SHA512:
6
+ metadata.gz: 4c186c16ac445cf75f51dc54759c6ba3d6ac469f9c53dc17631059242318ee27610bad0b7d06fdba025ca6008541157badb4cd99c9efe354fbdd54a4982a724a
7
+ data.tar.gz: 5328a77d64bc55bc00f15f6ed5c5a4ef58d7acfba39df55531c2f94be84da5e327b26e85ccf2afe68a9d08e4d1a4149875d2b82bd74e829e101af7ce0df2c3f0
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ require:
4
+ - rubocop-powerhome
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.7
8
+
9
+ Rails:
10
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,7 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config --exclude-limit 500`
3
+ # on 2022-08-11 19:45:17 UTC using RuboCop version 1.29.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ git_source(:github) do |repo_name|
5
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
6
+ "https://github.com/#{repo_name}.git"
7
+ end
8
+
9
+ gemspec
10
+
11
+ rails_version = ENV.fetch("RAILS_VERSION", ">= 5.2.8.1")
12
+
13
+ gem "rails", rails_version
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env rake
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require "rspec/core/rake_task"
6
+ require "rubocop/rake_task"
7
+
8
+ begin
9
+ require "bundler/setup"
10
+ rescue LoadError
11
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
12
+ end
13
+ begin
14
+ require "yard"
15
+ YARD::Rake::YardocTask.new do |t|
16
+ t.files = ["lib/**/*.rb"]
17
+ t.options = [
18
+ "--no-private",
19
+ ]
20
+ end
21
+ rescue LoadError
22
+ warn "Could not require() YARD! Install with 'gem install yard' to get the 'yardoc' task"
23
+ end
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ RSpec::Core::RakeTask.new(:spec)
28
+
29
+ RuboCop::RakeTask.new(:rubocop)
30
+
31
+ task default: %i[spec rubocop]
data/config.ru ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+
6
+ Bundler.require :default, :development
7
+
8
+ Combustion.initialize! :all
9
+ run Combustion::Application
@@ -0,0 +1,3 @@
1
+ ---
2
+ - - :inherit_from
3
+ - https://raw.githubusercontent.com/powerhome/oss-guide/master/license_rules.yml
data/docs/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Lumberaxe
2
+
3
+ Lumberaxe handles logging output formatting.
4
+
5
+ # Usage
6
+
7
+ After installing the gem, require it as part of your application configuration.
8
+
9
+ ```ruby
10
+ # application.rb
11
+
12
+ require "lumberaxe"
13
+ ```
14
+
15
+ ## Setting JSON logging
16
+
17
+ To set up JSON logging on puma, add this to your puma config:
18
+
19
+ ```ruby
20
+ # puma.rb
21
+
22
+ log_formatter(&Lumberaxe.puma_formatter)
23
+ ```
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/tagged_logging"
4
+
5
+ module Lumberaxe
6
+ class JSONFormatter < ::Logger::Formatter
7
+ include ActiveSupport::TaggedLogging::Formatter
8
+
9
+ def call(severity, time, progname, data)
10
+ data = data.is_a?(Hash) ? format_data(data) : { message: data.to_s }
11
+
12
+ {
13
+ level: severity,
14
+ time: time,
15
+ progname: progname,
16
+ }.merge(data).to_json.concat("\r\n")
17
+ end
18
+
19
+ def format_data(data)
20
+ data.merge!(current_tags.each_with_object({}) do |tag, hash|
21
+ if tag.include?("=")
22
+ key, value = tag.split("=")
23
+ hash[key] = value
24
+ else
25
+ hash[:tags] ||= []
26
+ hash[:tags] << key
27
+ end
28
+ hash
29
+ end)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lumberaxe
4
+ class Logger < ::ActiveSupport::Logger
5
+ cattr_accessor :log_level
6
+
7
+ def initialize(output = $stdout, progname:, level: log_level)
8
+ super output
9
+
10
+ self.progname = progname
11
+ self.level = level
12
+
13
+ self.formatter = JSONFormatter.new
14
+ extend ActiveSupport::TaggedLogging
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lograge"
4
+
5
+ module Lumberaxe
6
+ class Railtie < Rails::Railtie
7
+ initializer "lumberaxe.configurations", before: :initialize_logger do |app|
8
+ Rails.logger = app.config.logger || Lumberaxe::Logger.new(progname: "app", level: app.config.log_level)
9
+
10
+ app.config.log_tags = [
11
+ ->(req) { "request_id=#{req.uuid}" },
12
+ ->(req) { "IP=#{req.remote_ip}" },
13
+ ]
14
+
15
+ Lumberaxe::Logger.log_level = app.config.log_level
16
+ end
17
+
18
+ initializer "lumberaxe.lograge" do
19
+ config.lograge.enabled = true
20
+ config.lograge.formatter = Lograge::Formatters::Raw.new
21
+ config.lograge.custom_options = ->(event) do
22
+ { "params" => event.payload[:params].without("controller", "action") }
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lumberaxe
4
+ VERSION = "0.1.0"
5
+ end
data/lib/lumberaxe.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+ require "active_support"
5
+ require "lumberaxe/railtie" if defined?(Rails)
6
+ require "lumberaxe/logger"
7
+ require "lumberaxe/json_formatter"
8
+
9
+ module Lumberaxe
10
+ def self.puma_formatter(level: "INFO", progname: "puma")
11
+ ->(message) do
12
+ {
13
+ level: level,
14
+ time: Time.now,
15
+ progname: progname,
16
+ message: message,
17
+ }.to_json.concat("\r\n")
18
+ end
19
+ end
20
+ end
data/lumberaxe.gemspec ADDED
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/lumberaxe/version"
4
+
5
+ $LOAD_PATH.push File.expand_path("lib", __dir__)
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "lumberaxe"
9
+ spec.version = Lumberaxe::VERSION
10
+ spec.authors = ["Carlos Palhares", "Jill Klang"]
11
+ spec.email = ["chjunior@gmail.com", "jillian.emilie@gmail.com"]
12
+
13
+ spec.summary = "Power-ful logging wrapper"
14
+ spec.description = "Lumberaxe handles logging output formatting."
15
+ spec.homepage = "https://github.com/powerhome/power-tools"
16
+ spec.license = "MIT"
17
+ spec.required_ruby_version = ">= 2.7"
18
+
19
+ spec.metadata["rubygems_mfa_required"] = "true"
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = spec.homepage
22
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/packages/lumberaxe/docs/CHANGELOG.md"
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(__dir__) do
27
+ `git ls-files -z`.split("\x0").reject do |f|
28
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
29
+ end
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_dependency "activesupport", ">= 5.2.8.1"
36
+ spec.add_dependency "lograge", "0.10.0"
37
+
38
+ spec.add_development_dependency "bundler", "~> 2.1"
39
+ spec.add_development_dependency "combustion", "~> 1.3"
40
+ spec.add_development_dependency "license_finder", ">= 7.0"
41
+ spec.add_development_dependency "parser", ">= 2.5", "!= 2.5.1.1"
42
+ spec.add_development_dependency "pry-byebug", "3.9.0"
43
+ spec.add_development_dependency "rails", ">= 5.2.8.1"
44
+ spec.add_development_dependency "rainbow", "2.2.2"
45
+ spec.add_development_dependency "rake", "~> 13.0"
46
+ spec.add_development_dependency "rspec", "~> 3.0"
47
+ spec.add_development_dependency "rspec-rails", "~> 5.1.2"
48
+ spec.add_development_dependency "rubocop-powerhome", "0.5.0"
49
+ spec.add_development_dependency "simplecov", "0.15.1"
50
+ spec.add_development_dependency "sqlite3", "~> 1.4.2"
51
+ spec.add_development_dependency "test-unit", "3.1.5"
52
+ spec.add_development_dependency "yard", "0.9.21"
53
+ end
data/mkdocs.yml ADDED
@@ -0,0 +1,5 @@
1
+ site_name: Lumberaxe
2
+ nav:
3
+ - "Home": "README.md"
4
+ plugins:
5
+ - techdocs-core
data/test.sh ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ bin/setup
6
+ bin/build
7
+ bin/doc
8
+ bin/test
metadata ADDED
@@ -0,0 +1,308 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lumberaxe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Carlos Palhares
8
+ - Jill Klang
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2022-08-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 5.2.8.1
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 5.2.8.1
28
+ - !ruby/object:Gem::Dependency
29
+ name: lograge
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '='
33
+ - !ruby/object:Gem::Version
34
+ version: 0.10.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '='
40
+ - !ruby/object:Gem::Version
41
+ version: 0.10.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.1'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.1'
56
+ - !ruby/object:Gem::Dependency
57
+ name: combustion
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.3'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.3'
70
+ - !ruby/object:Gem::Dependency
71
+ name: license_finder
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '7.0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '7.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: parser
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '2.5'
91
+ - - "!="
92
+ - !ruby/object:Gem::Version
93
+ version: 2.5.1.1
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '2.5'
101
+ - - "!="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.5.1.1
104
+ - !ruby/object:Gem::Dependency
105
+ name: pry-byebug
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 3.9.0
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 3.9.0
118
+ - !ruby/object:Gem::Dependency
119
+ name: rails
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 5.2.8.1
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 5.2.8.1
132
+ - !ruby/object:Gem::Dependency
133
+ name: rainbow
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 2.2.2
139
+ type: :development
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 2.2.2
146
+ - !ruby/object:Gem::Dependency
147
+ name: rake
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '13.0'
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '13.0'
160
+ - !ruby/object:Gem::Dependency
161
+ name: rspec
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '3.0'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '3.0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: rspec-rails
176
+ requirement: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 5.1.2
181
+ type: :development
182
+ prerelease: false
183
+ version_requirements: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 5.1.2
188
+ - !ruby/object:Gem::Dependency
189
+ name: rubocop-powerhome
190
+ requirement: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
193
+ - !ruby/object:Gem::Version
194
+ version: 0.5.0
195
+ type: :development
196
+ prerelease: false
197
+ version_requirements: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '='
200
+ - !ruby/object:Gem::Version
201
+ version: 0.5.0
202
+ - !ruby/object:Gem::Dependency
203
+ name: simplecov
204
+ requirement: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '='
207
+ - !ruby/object:Gem::Version
208
+ version: 0.15.1
209
+ type: :development
210
+ prerelease: false
211
+ version_requirements: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - '='
214
+ - !ruby/object:Gem::Version
215
+ version: 0.15.1
216
+ - !ruby/object:Gem::Dependency
217
+ name: sqlite3
218
+ requirement: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: 1.4.2
223
+ type: :development
224
+ prerelease: false
225
+ version_requirements: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: 1.4.2
230
+ - !ruby/object:Gem::Dependency
231
+ name: test-unit
232
+ requirement: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - '='
235
+ - !ruby/object:Gem::Version
236
+ version: 3.1.5
237
+ type: :development
238
+ prerelease: false
239
+ version_requirements: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - '='
242
+ - !ruby/object:Gem::Version
243
+ version: 3.1.5
244
+ - !ruby/object:Gem::Dependency
245
+ name: yard
246
+ requirement: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - '='
249
+ - !ruby/object:Gem::Version
250
+ version: 0.9.21
251
+ type: :development
252
+ prerelease: false
253
+ version_requirements: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - '='
256
+ - !ruby/object:Gem::Version
257
+ version: 0.9.21
258
+ description: Lumberaxe handles logging output formatting.
259
+ email:
260
+ - chjunior@gmail.com
261
+ - jillian.emilie@gmail.com
262
+ executables: []
263
+ extensions: []
264
+ extra_rdoc_files: []
265
+ files:
266
+ - ".rubocop.yml"
267
+ - ".rubocop_todo.yml"
268
+ - Gemfile
269
+ - Rakefile
270
+ - config.ru
271
+ - doc/dependency_decisions.yml
272
+ - docs/README.md
273
+ - lib/lumberaxe.rb
274
+ - lib/lumberaxe/json_formatter.rb
275
+ - lib/lumberaxe/logger.rb
276
+ - lib/lumberaxe/railtie.rb
277
+ - lib/lumberaxe/version.rb
278
+ - lumberaxe.gemspec
279
+ - mkdocs.yml
280
+ - test.sh
281
+ homepage: https://github.com/powerhome/power-tools
282
+ licenses:
283
+ - MIT
284
+ metadata:
285
+ rubygems_mfa_required: 'true'
286
+ homepage_uri: https://github.com/powerhome/power-tools
287
+ source_code_uri: https://github.com/powerhome/power-tools
288
+ changelog_uri: https://github.com/powerhome/power-tools/blob/main/packages/lumberaxe/docs/CHANGELOG.md
289
+ post_install_message:
290
+ rdoc_options: []
291
+ require_paths:
292
+ - lib
293
+ required_ruby_version: !ruby/object:Gem::Requirement
294
+ requirements:
295
+ - - ">="
296
+ - !ruby/object:Gem::Version
297
+ version: '2.7'
298
+ required_rubygems_version: !ruby/object:Gem::Requirement
299
+ requirements:
300
+ - - ">="
301
+ - !ruby/object:Gem::Version
302
+ version: '0'
303
+ requirements: []
304
+ rubygems_version: 3.3.7
305
+ signing_key:
306
+ specification_version: 4
307
+ summary: Power-ful logging wrapper
308
+ test_files: []