hedgelog 0.1.9 → 0.1.11

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
- SHA1:
3
- metadata.gz: 6c95825590759e26acec2dd6439b31201c4ea529
4
- data.tar.gz: f007a3bf2d794f934700486792892a6435d90c62
2
+ SHA256:
3
+ metadata.gz: ad4599bd517f673d1e48ae116e245e7bd1359de3dd39f4b77c302a48c7d1314c
4
+ data.tar.gz: 6c20071765b9b90e2dadab72f2a6b03cdda3c773b1bc55cfb2650aeacb0b1e17
5
5
  SHA512:
6
- metadata.gz: 97d0762b2f93753ff04ead868df679673867f25bdb4eb6e9c50bf28d4c0bc9c09de34458f9befbacf334ab05b0d0ac761c2c3b56c854940aa46ea44b8a9c8a6c
7
- data.tar.gz: 47af20edfb870b7d11bdf151e3fd84dcc317a163a3569cb991d651a1a46ef00a582ce9dcfd5e074c702a667782120281c0f2e15e861076d475c1331c43589d08
6
+ metadata.gz: d5788a198de13d7d4cea307398ddf27d4fc6a61d02adeb1ceac90c191ae93a0ad2a39b9f1b9af54cf3770cd879542eaf953988da5a0187ec3afd15ca5f9b4165
7
+ data.tar.gz: bea33ebd32155d2604ffee833122dc0fff3cc93bccc37ad23a792bc73726b42f163ccf85e9650763ae0edb402a7fa6133d95c804afb7615dec16b78d8e201167
data/.rubocop.yml CHANGED
@@ -2,10 +2,10 @@
2
2
  inherit_from: #{RUBOCOP_HOME}/config/default.yml
3
3
 
4
4
  AllCops:
5
- Include:
6
- - '**/lib/**/*'
5
+ TargetRubyVersion: 2.4
7
6
  Exclude:
8
- - 'bin/**/*'
7
+ - 'vendor/**/*'
8
+ - 'Guardfile'
9
9
 
10
10
  CyclomaticComplexity:
11
11
  Max: 15
@@ -56,6 +56,12 @@ Style/StringLiterals:
56
56
  Enabled: true
57
57
  EnforcedStyle: single_quotes
58
58
 
59
- Style/BlockLength:
59
+ Metrics/BlockLength:
60
60
  Exclude:
61
61
  - 'spec/**/*.rb'
62
+
63
+ Style/FrozenStringLiteralComment:
64
+ Enabled: false
65
+
66
+ Style/AccessModifierDeclarations:
67
+ EnforcedStyle: inline
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4
data/.travis.yml CHANGED
@@ -1,26 +1,23 @@
1
1
  language: ruby
2
2
  cache: bundler
3
- rvm:
4
- - 2.3.0
5
- - 2.2.2
3
+ rvm: 2.4
6
4
  script:
7
- - bundle exec rspec
8
- - bundle exec rubocop lib spec
5
+ - bundle exec bundle-audit update && bundle exec bundle-audit check
6
+ - bundle exec rspec
7
+ - bundle exec rubocop lib spec
9
8
  deploy:
10
9
  - provider: releases
11
10
  api_key:
12
- secure: Ob2+ZdkM5msawA9FnJ8hk7wLgUP9tJg+gOIs1VOpOzq7cqHUmbK2tGwJPSWX+yzFA5A9o520SLJB0MAfnO78DjByRenH1e8keg0uxZ17ci8FDWEPhF53cCjuTLhsaC9qxVcbNps4Z8pg5lQ/0IPaef0lVX0u2jPEHagNBmfJdYLthUPH/M/AcoVT/chjxWw3SNON4LdcUQw5qtpMUe/Clroi5LaaYPWui0o7z6EmlqwV0gFd5oVkXabwuMkWU06tFzxO+AgBT7qeMCDSXqa2ODaWItE74i8TVEMRDHiY+0a0gs76xjsfkml4Q0dNw8YuKcO4p25QskNeTtxi3rZoMToG4e8MfHZG+3YLu3u9VKp0fR7WsL21Jf27dDscXapXyVcMZ+AcklRMEGmKjsyKPnxepcR5RtmoVbDY9/SnJfECa62diZyzMYpjDvu4ZVut5vf/m8AvhnotpwTE2Nilb268f36uIloTG/5zrA113KiEAw5OW0abOm0JFn7t2bZty9D1rwyXiUGZmeS+ZFFE0+zCKXFv5VyK9ZmG4OKbGMMQJRsF+ej70Uv88MbwSS8TDRu0U1bnHBQ6aP3Wc7POihk9M2NAokFppQ9R0htVm0XWrDsxWnEqMMf8HZAQ8fsM9P1jZclgJKnzdSqpKjW4cGAk9i5+mepG6BcASfoUkhk=
11
+ secure: z/GBmPIgX/UQLixhUnN6fouJbC0PghjW8MeAJJoeIPNqKuv2Kws1wgNOndgrSb+U/gfIZ8CAHTq/U6hlfpGHt7+IBAmO/YMCH/O0CV/MNCfVKwduFTZplcDSnXAiFy77yk+ute0It/L/HJO1LMSq3q1wU2jUWL4CZal/+GY7yVFo8EZQJBeTmvatPd0uD+/+bFwEsYEGKt2/JF42GW6Xtbt9DHXwL1olYmReuPjXavdomZof0KKboM+cI42gzJ5AYVl4ouELGiGQgh5dgK1HkvpBGYqg16YgT0LK5HnQ24slwJk2+yM6x9bXZqQu8IEhPafxR77wJ6T0388iM5vCXtzzJidsOL6mANqpKZ8z1YsAi0w4QNAPvf2AFw40fIfu2W/J4z2UYQUKD/3Em1IY0/fPr+FdMBMWQNevjjns89943GWhFoDUJj4EMt46rEpMHPVTA9DfUA7be4IRo9YrUx7u8MaVotpzSYCxepAmC9tB7KQAjygxI7z/orihZj7lHadUI8rPKfKUkrDDwSyB8xyV5BjpcorSshoqnFLaGrxHfbos/ww5i2xxQEF77RK9rkaICyE7q6oOghCq7BSKsYVzNkBCtRftVy5zYCEPd8MCXxF40S3uv4ta30wQKhdZPWELf4GkzKxCpdbbryWQKoF6ZKceD+LIG18qVlO5AqU=
13
12
  file_glob: true
14
13
  file: hedgelog-*.gem
15
14
  on:
16
15
  tags: true
17
- rvm: 2.2.2
18
16
  repo: firespring/hedgelog
19
17
  - provider: rubygems
20
18
  api_key:
21
- secure: 0lJg8R4FfcC/V0CQP1+MtvaOTHumMczV6W5wNvW+S4C9A+EhWgNdZDZ1tPbLQDRm4rBhr15k6KpZUmR1hMiu2xpN/O9wpdLqrhFccnP8+3qSYWi4Mqns/lFLQtVwlfQeSjQPejHeel7wEDAo/iFs9lgVzyXtusAgIZ8qQLJIa2T8cLE5Kdh/xfJTfdYCojJkw+5XoxARFmiXz5dIBb+1jiYmAULgRQpNUifz+IspAUxDf8BXjZFi7TZeKf34kOnVRUXLdjFOkTIXSx7F1NlSCFUmQtjf1Ft1PfJUwZ+eh5B0u5AL7JMA3pA9T6WNpqJpedVCD5KvkqKeILYFkYriro7K41MCPXBM4CAXSgpqnwiGCR64eBm85nGaRbYIZ+8AdGKxd1wS+fVkpOv4PxDADDD+qPIVTpuTeIJ2+hZYpHdsD5bYtqhvqdUkVOdilnBZKFYHVwHZvkObOoGyk0g3PzwYOUSnG3BJ3YhinTzNuXkOBhUdGN/eZna314hPLVGySTlmpnnof2lWQFArJXTcJXVQBdkSdlML7vvv4QjttOBNX6ICzOimFDrTDIlf3hkrf3+bGva3v0tBn3cz4bLOZgdvWrhhJ+p6TzPCGoseKUE2e+zvBAsPEzjYI9G+hKkSbtT0rFZ6O/Cr21dL/Mbf2WMz0NfhmTc4J3kdP2Y98Ow=
19
+ secure: anM34Z3fd3H5xt46pVbOmC0FnPsD0Pro9+Vmdv4fq22GvjFolexCtNFt8fb8V+M9THvw1qZDvSyHTZ0NKUDMqaVLX+VhDvquhuM0vviAECBu7kqqZ/pBjBJduYrtcFrCpoL3vs3AhXM882XKIhw4YMtOgoh00DpLZYQbtdEVvCZhbIe80N2eRSM1taVNQQwkI7pREBBFliBrjpP82Vfacue7m/iDKg/k1SRv1jXafQLDM0k8UAdYntc/popqTpXCbmxOcPVv6yVghijld6rTirLeRSrbwq1m0Djg24r/BGd8NsFn9Xtvtm8oZN3Xv2Q8AoJFeDCymTndUtJYrFaS8IQe5TLzXLYW+/BjedCuA09bfcRjW7vjuO73yYqf/K+dTbwbuJMpUJt6Mymu66MuPi6ntj00hvDBU9ekHFkZlemUixq3LxvmEPyxK8PKTLVH9UipkTBG0cXWct5fCXhv0KvrxFLeZM2XXqvknnuYGSIE5fvGLHvn2OuX5JESJzwDt8xBNXrPmCIcDX/DOONR+AuPYQkDLybM75/P+vnxSfT6ZMFj7AxZAr23mWOQ1dK+dgvJb+nbBa+5KRCPs9n9M4aW5ybNKgy8v8Mgp6ebTuRLYDUdOB2aMXRy6/0dqSMR+fe0B7HtHXNtp73Nidox6QBFQzmtXg8fzsXA9yFKFZI=
22
20
  gem: hedgelog
23
21
  on:
24
22
  tags: true
25
- rvm: 2.2.2
26
23
  repo: firespring/hedgelog
data/Gemfile CHANGED
@@ -4,17 +4,18 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test, :development do
7
- gem "rake", "~> 10.0"
8
- gem "rspec", "~> 3.3"
9
- gem "pry"
10
- gem "simplecov", "~> 0.10"
11
- gem "rubocop", "~> 0.33"
12
- gem "timecop"
13
7
  gem 'benchmark-ips'
8
+ gem 'bundler-audit'
9
+ gem 'pry'
10
+ gem 'rake'
11
+ gem 'rspec'
12
+ gem 'rubocop'
13
+ gem 'simplecov'
14
+ gem 'timecop'
14
15
  end
15
16
 
16
17
  group :development do
17
- gem 'ruby-prof'
18
18
  gem 'guard-rspec', require: false
19
19
  gem 'listen', '~> 3.0.6'
20
+ gem 'ruby-prof'
20
21
  end
data/Guardfile CHANGED
@@ -24,8 +24,8 @@
24
24
  # * zeus: 'zeus rspec' (requires the server to be started separately)
25
25
  # * 'just' rspec: 'rspec'
26
26
 
27
- guard :rspec, cmd: "bundle exec rspec --format progress" do
28
- require "guard/rspec/dsl"
27
+ guard :rspec, cmd: 'bundle exec rspec --format progress' do
28
+ require 'guard/rspec/dsl'
29
29
  dsl = Guard::RSpec::Dsl.new(self)
30
30
 
31
31
  # Feel free to open issues for suggestions and improvements
@@ -41,15 +41,15 @@ guard :rspec, cmd: "bundle exec rspec --format progress" do
41
41
  dsl.watch_spec_files_for(ruby.lib_files)
42
42
 
43
43
  # Rails files
44
- rails = dsl.rails(view_extensions: %w(erb haml slim))
44
+ rails = dsl.rails(view_extensions: %w[erb haml slim])
45
45
  dsl.watch_spec_files_for(rails.app_files)
46
46
  dsl.watch_spec_files_for(rails.views)
47
47
 
48
48
  watch(rails.controllers) do |m|
49
49
  [
50
- rspec.spec.("routing/#{m[1]}_routing"),
51
- rspec.spec.("controllers/#{m[1]}_controller"),
52
- rspec.spec.("acceptance/#{m[1]}")
50
+ rspec.spec.call("routing/#{m[1]}_routing"),
51
+ rspec.spec.call("controllers/#{m[1]}_controller"),
52
+ rspec.spec.call("acceptance/#{m[1]}")
53
53
  ]
54
54
  end
55
55
 
@@ -59,12 +59,12 @@ guard :rspec, cmd: "bundle exec rspec --format progress" do
59
59
  watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
60
 
61
61
  # Capybara features specs
62
- watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
63
- watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
62
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64
64
 
65
65
  # Turnip features and steps
66
66
  watch(%r{^spec/acceptance/(.+)\.feature$})
67
67
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
- Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
69
69
  end
70
70
  end
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Hedgelog
2
2
  [![Gem Version](https://badge.fury.io/rb/hedgelog.svg)](http://badge.fury.io/rb/hedgelog)
3
3
  [![Build Status](https://travis-ci.org/firespring/hedgelog.svg?branch=master)](https://travis-ci.org/firespring/hedgelog)
4
- [![Dependency Status](https://gemnasium.com/firespring/hedgelog.svg)](https://gemnasium.com/firespring/hedgelog)
5
- [![Code Climate](https://codeclimate.com/github/firespring/hedgelog/badges/gpa.svg)](https://codeclimate.com/github/firespring/hedgelog)
6
4
 
7
5
  This gem provides an opinionated Ruby logger for writing structured JSON logs. It attempts to maintain compatibility with the standard Ruby logger api while extending it with functionality relevant to JSON logging.
8
6
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "hedgelog"
3
+ require 'bundler/setup'
4
+ require 'hedgelog'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
- require "pry"
9
+ require 'pry'
10
10
  Pry.start
data/bin/profile CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "hedgelog"
3
+ require 'bundler/setup'
4
+ require 'hedgelog'
5
5
  require 'ruby-prof'
6
6
  require 'logger'
7
7
 
@@ -9,13 +9,12 @@ logger = Hedgelog.new('/dev/null')
9
9
  logger.level = Logger::INFO
10
10
 
11
11
  RubyProf.start
12
- 10000.times do
12
+ 10_000.times do
13
13
  logger.info 'Foo'
14
14
  end
15
15
  result = RubyProf.stop
16
16
  result.eliminate_methods!([/Integer#times/])
17
17
 
18
-
19
18
  # printer = RubyProf::GraphPrinter.new(result)
20
19
  printer = RubyProf::FlatPrinterWithLineNumbers.new(result)
21
20
  printer.print(STDOUT)
data/hedgelog.gemspec CHANGED
@@ -1,25 +1,23 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'hedgelog/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "hedgelog"
6
+ spec.name = 'hedgelog'
8
7
  spec.version = Hedgelog::VERSION
9
8
  spec.licenses = ['MIT']
10
- spec.authors = ["Jeff Utter"]
11
- spec.email = ["jeff.utter@firespring.com"]
12
- spec.homepage = 'https://github.com/firespring/hedgelog'
9
+ spec.authors = ['Jeff Utter']
10
+ spec.email = ['jeff.utter@firespring.com']
13
11
 
14
- spec.summary = "An opinionated/strucutred JSON logger for Ruby"
15
- spec.description = "An opinionated/structured JSON logger for Ruby"
16
- spec.homepage = "http://firespring.com"
12
+ spec.homepage = 'https://github.com/firespring/hedgelog'
13
+ spec.summary = 'A strucutred JSON logger for Ruby'
14
+ spec.description = 'An opinionated/structured JSON logger for Ruby'
17
15
 
18
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- spec.bindir = "exe"
17
+ spec.bindir = 'exe'
20
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
22
20
 
23
- spec.add_dependency "yajl-ruby", "~> 1.2"
24
- spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_dependency 'yajl-ruby', '~> 1.4'
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
25
23
  end
@@ -5,6 +5,7 @@ class Hedgelog
5
5
  class Context
6
6
  def initialize(scrubber, normalizer, data = {})
7
7
  raise ::ArgumentError, "#{self.class}: argument must be Hash got #{data.class}." unless data.is_a? Hash
8
+
8
9
  check_reserved_keys(data)
9
10
  @data = data
10
11
  @scrubber = scrubber
@@ -61,9 +62,7 @@ class Hedgelog
61
62
  @data
62
63
  end
63
64
 
64
- private
65
-
66
- def check_reserved_keys(hash)
65
+ private def check_reserved_keys(hash)
67
66
  invalid_keys = Hedgelog::RESERVED_KEYS & hash.keys
68
67
  raise ::ArgumentError, "#{self.class}: The following keys are reserved and cannot be used #{invalid_keys.to_a}." unless invalid_keys.empty?
69
68
  end
@@ -1,12 +1,10 @@
1
1
  class Hedgelog
2
2
  class Normalizer
3
- # rubocop:disable Security/MarshalLoad
4
3
  def normalize(data)
5
4
  # Need to Marshal.dump/Marshal.load to deep copy the input so that scrubbing doesn't change global state
6
5
  d = Marshal.load(Marshal.dump(data))
7
6
  normalize_hash(d)
8
7
  end
9
- # rubocop:enable Security/MarshalLoad
10
8
 
11
9
  def normalize_struct(struct)
12
10
  normalize_hash(Hash[struct.each_pair.to_a])
@@ -22,14 +20,14 @@ class Hedgelog
22
20
  array.to_json
23
21
  end
24
22
 
25
- private
26
-
27
- def normalize_thing(thing)
23
+ private def normalize_thing(thing)
28
24
  return '' if thing.nil?
25
+
29
26
  thing = thing.as_json if thing.respond_to?(:as_json)
30
27
  return normalize_struct(thing) if thing.is_a?(Struct)
31
28
  return normalize_array(thing) if thing.is_a?(Array)
32
29
  return normalize_hash(thing) if thing.is_a?(Hash)
30
+
33
31
  thing
34
32
  end
35
33
  end
@@ -18,6 +18,7 @@ class Hedgelog
18
18
  def scrub_hash(hash)
19
19
  hash.each do |key, val|
20
20
  next hash[key] = @replacement if key.to_s.casecmp(@key.to_s).zero?
21
+
21
22
  scrub_thing(val)
22
23
  end
23
24
  end
@@ -28,9 +29,7 @@ class Hedgelog
28
29
  end
29
30
  end
30
31
 
31
- private
32
-
33
- def scrub_thing(thing)
32
+ private def scrub_thing(thing)
34
33
  scrub_string(thing) if thing.is_a?(String)
35
34
  scrub_array(thing) if thing.is_a?(Array)
36
35
  scrub_hash(thing) if thing.is_a?(Hash)
@@ -8,7 +8,6 @@ class Hedgelog
8
8
  ]
9
9
  end
10
10
 
11
- # rubocop:disable Security/MarshalLoad
12
11
  def scrub(data)
13
12
  # Need to Marshal.dump/Marshal.load to deep copy the input so that scrubbing doesn't change global state
14
13
  d = Marshal.load(Marshal.dump(data))
@@ -17,6 +16,5 @@ class Hedgelog
17
16
  end
18
17
  d
19
18
  end
20
- # rubocop:enable Security/MarshalLoad
21
19
  end
22
20
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Hedgelog
3
- VERSION = '0.1.9'.freeze
4
+ VERSION = '0.1.11'
4
5
  end
data/lib/hedgelog.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'hedgelog/version'
3
4
  require 'hedgelog/context'
4
5
  require 'hedgelog/scrubber'
@@ -7,7 +8,7 @@ require 'logger'
7
8
  require 'yajl'
8
9
 
9
10
  class Hedgelog
10
- LEVELS = %w(DEBUG INFO WARN ERROR FATAL UNKNOWN).each_with_object({}).with_index do |(v, h), i|
11
+ LEVELS = %w[DEBUG INFO WARN ERROR FATAL UNKNOWN].each_with_object({}).with_index do |(v, h), i|
11
12
  h[v] = i
12
13
  h[v.downcase] = i
13
14
  h[v.to_sym] = i
@@ -15,11 +16,11 @@ class Hedgelog
15
16
  h[i] = v.downcase.to_sym
16
17
  end.freeze
17
18
 
18
- TOP_LEVEL_KEYS = [:app, :channel, :level, :level_name, :message, :request_id, :timestamp].freeze
19
- RESERVED_KEYS = [:app, :level, :level_name, :timestamp, :context, :caller].freeze
19
+ TOP_LEVEL_KEYS = %i[app channel level level_name message request_id timestamp].freeze
20
+ RESERVED_KEYS = %i[app level level_name timestamp context caller].freeze
20
21
 
21
- TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%M:%S.%6N%z'.freeze
22
- BACKTRACE_RE = /([^:]+):([0-9]+)(?::in `(.*)')?/
22
+ TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%M:%S.%6N%z'
23
+ BACKTRACE_RE = Regexp.new("([^:]+):([0-9]+)(?::in `(.*)')?")
23
24
 
24
25
  attr_reader :level
25
26
  attr_writer :app
@@ -43,6 +44,7 @@ class Hedgelog
43
44
  def level=(level)
44
45
  int_level = level_to_int(level)
45
46
  raise ::ArgumentError, "#{self.class}#level= , #{level} is not a valid level." if int_level.nil?
47
+
46
48
  @level = int_level
47
49
  end
48
50
 
@@ -58,7 +60,7 @@ class Hedgelog
58
60
 
59
61
  return write(severity, context) if @logdev
60
62
 
61
- @channel.add(severity, nil, progname, context) if @channel
63
+ @channel&.add(severity, nil, progname, context)
62
64
  end
63
65
 
64
66
  def []=(key, val)
@@ -86,7 +88,7 @@ class Hedgelog
86
88
  sc
87
89
  end
88
90
 
89
- %w(fatal error warn info debug unknown).each do |level|
91
+ %w[fatal error warn info debug unknown].each do |level|
90
92
  predicate = "#{level}?".to_sym
91
93
  level = level.to_sym
92
94
 
@@ -118,23 +120,23 @@ class Hedgelog
118
120
  ::Logger::Formatter.new
119
121
  end
120
122
 
121
- def formatter=(_)
123
+ def formatter=(_value)
122
124
  formatter
123
125
  end
124
126
 
125
- private
126
-
127
- def level_to_int(level)
127
+ private def level_to_int(level)
128
128
  return level if level.is_a?(Integer)
129
+
129
130
  LEVELS[level]
130
131
  end
131
132
 
132
- def level_from_int(level)
133
+ private def level_from_int(level)
133
134
  return LEVELS[level] if level.is_a?(Integer)
135
+
134
136
  level.to_sym
135
137
  end
136
138
 
137
- def write(severity, context)
139
+ private def write(severity, context)
138
140
  return true if @logdev.nil?
139
141
 
140
142
  context.normalize!
@@ -142,14 +144,14 @@ class Hedgelog
142
144
 
143
145
  data = context.merge(default_data(severity))
144
146
  data[:app] = @app if @app
145
- data[:caller] = debugharder(caller[3]) if debug?
147
+ data[:caller] = debugharder(caller(4, 1).first) if debug?
146
148
  data = extract_top_level_keys(data)
147
149
 
148
150
  @logdev.write(Yajl::Encoder.encode(data) + "\n")
149
151
  true
150
152
  end
151
153
 
152
- def default_data(severity)
154
+ private def default_data(severity)
153
155
  {
154
156
  timestamp: Time.now.strftime(TIMESTAMP_FORMAT),
155
157
  level_name: level_from_int(severity),
@@ -157,7 +159,7 @@ class Hedgelog
157
159
  }
158
160
  end
159
161
 
160
- def extract_top_level_keys(context)
162
+ private def extract_top_level_keys(context)
161
163
  data = {}
162
164
  TOP_LEVEL_KEYS.each do |key|
163
165
  data[key] = context.delete(key) if context.key? key
@@ -166,9 +168,10 @@ class Hedgelog
166
168
  data
167
169
  end
168
170
 
169
- def debugharder(callinfo)
171
+ private def debugharder(callinfo)
170
172
  m = BACKTRACE_RE.match(callinfo)
171
173
  return unless m
174
+
172
175
  path, line, method = m[1..3]
173
176
  whence = $LOAD_PATH.find { |p| path.start_with?(p) }
174
177
  file = if whence
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hedgelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Utter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2018-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.2'
19
+ version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.2'
26
+ version: '1.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -46,9 +46,9 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
- - ".hound.yml"
50
49
  - ".rspec"
51
50
  - ".rubocop.yml"
51
+ - ".ruby-version"
52
52
  - ".simplecov"
53
53
  - ".travis.yml"
54
54
  - CONTRIBUTING.md
@@ -68,7 +68,7 @@ files:
68
68
  - lib/hedgelog/scrub_replacement.rb
69
69
  - lib/hedgelog/scrubber.rb
70
70
  - lib/hedgelog/version.rb
71
- homepage: http://firespring.com
71
+ homepage: https://github.com/firespring/hedgelog
72
72
  licenses:
73
73
  - MIT
74
74
  metadata: {}
@@ -88,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.4.8
91
+ rubygems_version: 2.7.7
92
92
  signing_key:
93
93
  specification_version: 4
94
- summary: An opinionated/strucutred JSON logger for Ruby
94
+ summary: A strucutred JSON logger for Ruby
95
95
  test_files: []
data/.hound.yml DELETED
@@ -1,2 +0,0 @@
1
- ruby:
2
- config_file: .rubocop.yml