hedgelog 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTBjNzlhNzAzZDkwYzkzY2I4NjdlODA3NmYwMTUzYjUxN2M3ZjQ2MA==
4
+ OTZjNDlkZDk3YTc3YzQwNGIzODBiOTI1ZmVmMDAyMTkzZjBjNzYxMw==
5
5
  data.tar.gz: !binary |-
6
- Y2EyZDYyNTY3ZmUwZGM3NDI5YTc2M2EwYzQxNWE3NjM0NzAwNTg0Yg==
6
+ YzQ2ZmZlZWU4Yjc4YWJkODQ3NmRlNmIwYTQ3YzdjMDg4MjhjYmU5Ng==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDhlYjdiYjNlMDE3ZjM0YWVlZDc1MjFkMzQ3NzdkOWI1MzE3OWIwYWQ3MGE2
10
- OTMwN2Y0ZTUyZmEyNDczOWQ3ZGZhMTdlYWEzMTg0MjA2ZTlmYmUxZTJlMzdk
11
- NGMwZTJmZDMwODcyYmYzZTEyMzQ3NjBhMDk3MjQ3ZmFkYjA5ZWQ=
9
+ YjNiMTc0MTUxZWIyNWYyZGNiZjU4NzM4NTgyYmVjOTdkYzNmMDkyNGFjZTA3
10
+ OWI5MjY5ZmE4MmFkNjgwZjE3YmE0NTA2ZmZhNzFkMGU1ZDM1NzE5NThhYjAz
11
+ YzMwMDAwYWRmNTI0YjQyNWQ5OTA5ODY5M2RlMDVmYzMyNDVhMTg=
12
12
  data.tar.gz: !binary |-
13
- ZTc2YzMwZjcwZTE2MTQ5YzA3NGRhNWQwMzRiZWU4MTgxMDBlYTQ5ZjE5NWYx
14
- OWJiNzE4OTFiNzhlNGE3YTA5ZWViNDZhMDU2NjZlMDFlNjE1NTA5NmFhYzdk
15
- ZDdkNWEyNDVkOWMzMjA4ZmVjYmY3ZGUyMWI2ZmQ2ODYxNTg0ZmQ=
13
+ NmRjZjcxODc3MWNmNjUyYmRiZTAyOWY5NGU5NDBiMTQzNjAzYjU1NzA2MTA1
14
+ NzU0Mzc0MmU5ZTZmMzYxODFjMDIyNWY0MWUzZGI4ZDFiZDBlNzA5NzQ4Njhj
15
+ MjRkZjQ5Yzk5NTcwOTVhNjgyYWU0YTY5ZWViYjA4YTlhZWQyNWU=
data/.travis.yml CHANGED
@@ -3,7 +3,6 @@ cache: bundler
3
3
  rvm:
4
4
  - 2.3.0
5
5
  - 2.2.2
6
- - 1.9.3
7
6
  script:
8
7
  - bundle exec rspec
9
8
  - bundle exec rubocop lib spec
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class Hedgelog
3
- VERSION = '0.1.7'.freeze
3
+ VERSION = '0.1.8'.freeze
4
4
  end
data/lib/hedgelog.rb CHANGED
@@ -21,6 +21,9 @@ class Hedgelog
21
21
  TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%M:%S.%6N%z'.freeze
22
22
  BACKTRACE_RE = /([^:]+):([0-9]+)(?::in `(.*)')?/
23
23
 
24
+ attr_reader :level
25
+ attr_writer :app
26
+
24
27
  def initialize(logdev = STDOUT, shift_age = nil, shift_size = nil)
25
28
  @level = LEVELS[:debug]
26
29
  @channel = nil
@@ -37,16 +40,12 @@ class Hedgelog
37
40
  end
38
41
  end
39
42
 
40
- attr_reader :level
41
-
42
43
  def level=(level)
43
44
  int_level = level_to_int(level)
44
45
  raise ::ArgumentError, "#{self.class}#level= , #{level} is not a valid level." if int_level.nil?
45
46
  @level = int_level
46
47
  end
47
48
 
48
- attr_writer :app
49
-
50
49
  def add(severity = LEVELS[:unknown], message = nil, progname = nil, context = {}, &block)
51
50
  return true if (@logdev.nil? && @channel.nil?) || severity < @level
52
51
 
@@ -106,15 +105,28 @@ class Hedgelog
106
105
  end
107
106
  end
108
107
 
108
+ def silence(temporary_level = LEVELS[:error])
109
+ old_level = level
110
+ self.level = temporary_level
111
+
112
+ yield self
113
+ ensure
114
+ self.level = old_level
115
+ end
116
+
117
+ def formatter
118
+ ::Logger::Formatter.new
119
+ end
120
+
109
121
  private
110
122
 
111
123
  def level_to_int(level)
112
- return level if level.is_a?(Fixnum)
124
+ return level if level.is_a?(Integer)
113
125
  LEVELS[level]
114
126
  end
115
127
 
116
128
  def level_from_int(level)
117
- return LEVELS[level] if level.is_a?(Fixnum)
129
+ return LEVELS[level] if level.is_a?(Integer)
118
130
  level.to_sym
119
131
  end
120
132
 
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.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Utter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-19 00:00:00.000000000 Z
11
+ date: 2016-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby