logplexer 0.1.0 → 0.2.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 +4 -4
- data/README.md +18 -2
- data/bin/console +2 -2
- data/lib/logplexer/version.rb +1 -1
- data/lib/logplexer.rb +18 -7
- data/logplexer-0.1.0.gem +0 -0
- data/logplexer.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 768e52baccfd7314fe57214c8a9f919410a22dc5
|
4
|
+
data.tar.gz: 6c48a6944d90e86d816d90f140bd593b5194636a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5c738748eedfaaa3730a283366adab333aa86c2bd2aaae31ff2b4dc85a02dc8bfb0d2fb5ddfa5a4a8f56916a40d498d274ac90d92b96ddc96c37eab59ae300b
|
7
|
+
data.tar.gz: 91ef8277db934f6c6b9848d7c1c766e9594f34247824169b3ff6955be1466e87efc5443cdb40ba35abd3aa47d5d81fbded94ffb1a2ee9416bfb3524a2d0a91b1
|
data/README.md
CHANGED
@@ -9,9 +9,14 @@ By default in a Rails app, it is set to log to standard out in `development` and
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'logplexer'
|
12
|
+
gem 'logplexer'
|
13
13
|
```
|
14
14
|
|
15
|
+
or
|
16
|
+
|
17
|
+
|
18
|
+
$ gem install logplexer
|
19
|
+
|
15
20
|
And then execute:
|
16
21
|
|
17
22
|
$ bundle
|
@@ -87,6 +92,11 @@ Or if you are in developmet and would like to have all instances of Logplexer be
|
|
87
92
|
|
88
93
|
and everything that isn't specifically marked as `verbose: false` will print the backtrace. Keep in mind that verbose only works when the input is an Exception type.
|
89
94
|
|
95
|
+
|
96
|
+
Likewise, if you are in development or test and would like to quiet all logs ( i.e. don't report any Logplexer errors ), just set `LOG_QUIET` to 'true':
|
97
|
+
|
98
|
+
ENV['LOG_QUIET'] = "true"
|
99
|
+
|
90
100
|
## Configuration
|
91
101
|
|
92
102
|
If your `RAILS_ENV` is set to `development` or `test`, Logplexer will set an environment variable called `LOG_TO_HB` as "false" if it is anything else, i.e. `production` or `staging`, `LOG_TO_HB` will be set to "true".
|
@@ -99,6 +109,12 @@ or
|
|
99
109
|
|
100
110
|
ENV['LOG_TO_HB'] = "false"
|
101
111
|
|
112
|
+
### Overriding log level
|
113
|
+
|
114
|
+
By default Logplexer will (as of version 0.2.0) log to Honeybadger only those errors with the log level of `error` or `fatal`. If you would like to adjust this, for example to log errors that are at or above `warn` for instance, just put this line in your: `config/initializers/logplexer.rb`:
|
115
|
+
|
116
|
+
ENV['LOG_MIN_HB'] = 'warn' # could also be debug, info, error or fatal
|
117
|
+
|
102
118
|
## Development
|
103
119
|
|
104
120
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -107,7 +123,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
107
123
|
|
108
124
|
## Contributing
|
109
125
|
|
110
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
126
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Fullscreen/logplexer.
|
111
127
|
|
112
128
|
|
113
129
|
## License
|
data/bin/console
CHANGED
data/lib/logplexer/version.rb
CHANGED
data/lib/logplexer.rb
CHANGED
@@ -15,19 +15,19 @@ module Logplexer
|
|
15
15
|
RUBY
|
16
16
|
end
|
17
17
|
|
18
|
-
def log( exception,
|
18
|
+
def log( exception, log_level, opts = {})
|
19
19
|
# We wrap the Honeybadger notify call so that in development,
|
20
20
|
# we actually see the errors. Then we can unwrap the REST errors
|
21
21
|
# if need be
|
22
22
|
return if exception.nil?
|
23
|
+
return if ENV['LOG_QUIET'] == 'true'
|
23
24
|
|
24
25
|
logfile = opts.delete( :logfile )
|
25
26
|
logger = Logger.new( logfile || STDOUT )
|
26
27
|
|
27
28
|
# Override the verbosity if LOG_VERBOSE is unset
|
28
29
|
verbose = ENV["LOG_VERBOSE"] == "true" ? true : opts.delete( :verbose )
|
29
|
-
|
30
|
-
if ENV['LOG_TO_HB'] == "true"
|
30
|
+
if ENV['LOG_TO_HB'] == "true" && above_min_log_level?( log_level )
|
31
31
|
#TODO: Maybe extend this to include other kinds of notifiers.
|
32
32
|
if exception.is_a? String
|
33
33
|
exception = { error_class: "Exception",
|
@@ -38,21 +38,32 @@ module Logplexer
|
|
38
38
|
# Make sure that the exception is an actual exception and
|
39
39
|
# not just a hash since Honeybadger accepts both
|
40
40
|
if exception.is_a? Exception
|
41
|
-
logger.send(
|
41
|
+
logger.send( log_level, exception.message )
|
42
42
|
if verbose
|
43
43
|
exception.backtrace.each do |entry|
|
44
|
-
logger.send(
|
44
|
+
logger.send( log_level, "> #{entry}" )
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
elsif exception.is_a? String
|
49
49
|
# Log just the string if thats what the user wants
|
50
|
-
logger.send(
|
50
|
+
logger.send( log_level, exception )
|
51
51
|
|
52
52
|
else
|
53
53
|
# Default kind of log for an object or whatevs
|
54
|
-
logger.send(
|
54
|
+
logger.send( log_level, exception.inspect )
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
def above_min_log_level?( p )
|
60
|
+
min = ENV["LOG_MIN_HB"] || 'error'
|
61
|
+
return priority( p ) >= priority( min )
|
62
|
+
end
|
63
|
+
|
64
|
+
def priority( level )
|
65
|
+
@priorities ||= { debug: 0, info: 1, warn: 2, error: 3, fatal: 4 }
|
66
|
+
@priorities[ level.to_sym ]
|
67
|
+
end
|
68
|
+
|
58
69
|
end
|
data/logplexer-0.1.0.gem
ADDED
Binary file
|
data/logplexer.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.10"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "pry"
|
25
26
|
spec.add_development_dependency "webmock"
|
26
27
|
spec.add_development_dependency "vcr"
|
27
28
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logplexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Canty
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: webmock
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,6 +127,7 @@ files:
|
|
113
127
|
- lib/logplexer.rb
|
114
128
|
- lib/logplexer/railtie.rb
|
115
129
|
- lib/logplexer/version.rb
|
130
|
+
- logplexer-0.1.0.gem
|
116
131
|
- logplexer.gemspec
|
117
132
|
homepage: ''
|
118
133
|
licenses:
|