loglevel 1.0.1 → 1.1.0

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
  SHA1:
3
- metadata.gz: '029c298d5ce2f964647c947a95ef214d6e5d207e'
4
- data.tar.gz: d5ea7fa65220d6a76e5ca9ed49f0526bcfc86747
3
+ metadata.gz: 13691fc54a23f08687bcde3b89f3023fc2402d9b
4
+ data.tar.gz: eca0acbd40c05f1d0d4bbc37a69ae11e7a1f1297
5
5
  SHA512:
6
- metadata.gz: 0fee1924b678abc449656572d8103141563cf35dde619e94ecd6e80ca17a885ca5775e5593d53c70a30408fd1aeba82824f50419540e828924353ce3c2ee1e67
7
- data.tar.gz: c109086212ea09e5b46d188a1147c8492697d13f1b541e692597c2c634932822abad34d495c7e19777a4fab1b02e74e29c8673870c576730fd294a12c6fc4426
6
+ metadata.gz: a57ae97f3b9fda400b5e85b8ec21592030dc31d9dd79fc441deb82490e8060106141c46f7c15e213d0605c255213469476af76552d427a29ec4cbd1e27f022e9
7
+ data.tar.gz: 2a77c5cb2f3a9bad5ad0bf7310c1e6070a3bebb90fbb95d9dc8bb26e57da9ba9c9a2cd6e8907fc3cb56b57042d2924f36d78e8d644a609a977b7f984d6b223f6
data/README.md CHANGED
@@ -29,7 +29,7 @@ environment variable. For instance:
29
29
  LOGLEVEL=DEBUG,NOAR,NOHTTP rails server
30
30
  ```
31
31
 
32
- would set the Rails logger level to `:debug` but would suppress messages from
32
+ would set the Rails logger level to `DEBUG` but would suppress messages from
33
33
  the ActiveRecord logger and the HttpLogger gem.
34
34
 
35
35
  Here are the available settings:
@@ -42,6 +42,7 @@ Here are the available settings:
42
42
  | INFO | Equivalent to config.log_level = :info |
43
43
  | DEBUG | Equivalent to config.log_level = :debug |
44
44
  | NOAR | Do not show ActiveRecord messages |
45
+ | HTTP | Show HTTP messages |
45
46
  | NOHTTP | Do not show HTTP messages |
46
47
  | NOHEADERS | Do not include response headers in HTTP log |
47
48
  | NOBODY | Do not include response body in HTTP log |
@@ -52,8 +53,25 @@ The examples in this document assume Loglevel is being used in a Rails
52
53
  environment but it doesn't depend on Rails and can be used in other contexts.
53
54
 
54
55
  There are specific options to handle Railsy logging scenarios: things like
55
- controlling ActiveRecord logging. There are also specific options for handling
56
- the HttpLogger gem.
56
+ controlling ActiveRecord logging.
57
+
58
+ ### HttpLogger
59
+
60
+ The HttpLogger gem works in a slightly different way. When we set the level for HttpLogger we are setting the level *at which* the HTTP messages are logged.
61
+
62
+ In the Loglevel environment this will be `:debug`, so you will only see HTTP messages if `LOGLEVEL=DEBUG`. If you want to see HTTP messages at a less verbose level then use the `HTTP` parameter when setting `LOGLEVEL`, like this:
63
+
64
+ ```sh
65
+ LOGLEVEL=INFO,HTTP rails server
66
+ ```
67
+
68
+ This will show all messages at `INFO` and above and will also show HTTP messages.
69
+
70
+ If you want to see `DEBUG` messages but *not* HTTP messages then use the `NOHTTP` parameter:
71
+
72
+ ```sh
73
+ LOGLEVEL=DEBUG,NOHTTP rails server
74
+ ```
57
75
 
58
76
  ### Rails initialization
59
77
 
@@ -51,7 +51,8 @@ module Loglevel
51
51
  # Setup for HttpLogger. Here we are setting the level at which to log HTTP
52
52
  # interactions
53
53
  def http_setup
54
- return unless http? && settings.http?
54
+ return unless http?
55
+ raise Loglevel::Exception::ClassNotLoggable, class_name unless settings.http?
55
56
  regular_setup
56
57
  additional_http_setup
57
58
  end
@@ -24,7 +24,7 @@ module Loglevel
24
24
  end
25
25
 
26
26
  def http_level_name
27
- @http_level_name ||= 'DEBUG' if http? && !settings.http?
27
+ @http_level_name ||= settings.level if http? && settings.http?
28
28
  end
29
29
 
30
30
  def active_record_level_name
@@ -8,19 +8,19 @@ module Loglevel
8
8
  end
9
9
 
10
10
  def http?
11
- !lookup('NOHTTP')
11
+ @http ||= lookup('HTTP') || (level == 'DEBUG' && !lookup('NOHTTP'))
12
12
  end
13
13
 
14
14
  def active_record?
15
- !lookup('NOAR')
15
+ @active_record ||= !lookup('NOAR')
16
16
  end
17
17
 
18
18
  def response_body?
19
- !lookup('NOBODY')
19
+ @response_body ||= !lookup('NOBODY')
20
20
  end
21
21
 
22
22
  def request_headers?
23
- !lookup('NOHEADERS')
23
+ @request_headers ||= !lookup('NOHEADERS')
24
24
  end
25
25
 
26
26
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Loglevel
4
- VERSION = '1.0.1'.freeze
4
+ VERSION = '1.1.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loglevel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Sayers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-03 00:00:00.000000000 Z
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple gem to control logging at runtime with an environment variable
14
14
  email: