xlog 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: 8f8c4b408bed2b724d342f1011d4087c03096be8ba82385f59bc90efc807f288
4
- data.tar.gz: 98588cfff8b14c4ef2ccba1200afa1c3e2f07d7c2b5f517cbc4d382b46c00fee
3
+ metadata.gz: 5175ddef67a168d0ba5a200ddeb9efdc88dcdd98ccedd615ad26b2bedd2c3ef3
4
+ data.tar.gz: e150396dd1caaced0ddefc4e34c48cb5e2868985bb615b1671718a4dc6fe4600
5
5
  SHA512:
6
- metadata.gz: f99b0edc82187159cb80ec3100dc6596b93fe607e7101766c95d336ca5fe299121802d027cf2bd5541e6d03ab4520a4a92b95f199f1b4b74e9106a5def1fc796
7
- data.tar.gz: 1fb0fef01f3de76c0d653c42fbc044021be72cb8c47a2df6e15501e468ab1b64e30c61dd9cd2d85cead3405f4aea2494f4cea29f17706b0a3250a10f0d92c54d
6
+ metadata.gz: f5ee9f1686a38080d1f9b20c51013032ac4d3fc1c46e6e0b9a8c1dcd3ee20279fa3dda20ba7c1f5365f4e62f9b33fa03913ac50440e91f55e84ea6e7684629e3
7
+ data.tar.gz: bbb8f13f909d632a78377a6618c93984549a48c75526bbf73293ebcb49bf5af90c52e1183109ab4ba3ca70282fc579d2fc895286e6750e830e4c325fb551a737
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
- # Xlog v0.1.3
1
+ # Xlog v0.1.4
2
2
 
3
3
  Xlog - awesome logger for your Rails app. Logs everything you need in well-formatted view with timestamp, caller path and tags.
4
4
 
5
5
  ## Usage
6
+ ##### Standard
6
7
  Log any info with `.info` method
7
8
  ```ruby
8
9
  Xlog.info('Some info text') # [2019-04-30 12:29:13 UTC] [ArtilesController.show] [info] Message: Some info text
@@ -45,6 +46,18 @@ Clear tags with:
45
46
  ```ruby
46
47
  Xlog.clear_tags
47
48
  ```
49
+ ##### Middleware
50
+ From version 0.1.4 Xlog could be used as Rails middleware. It catches `StandardError` using `Xlog.and_raise_error`.
51
+ ```ruby
52
+ # /config/application.rb
53
+ module MyApp
54
+ class Application < Rails::Application
55
+ # some configs...
56
+
57
+ config.middleware.use Xlog::Middleware
58
+ end
59
+ end
60
+ ```
48
61
 
49
62
  ## Configuration
50
63
  Xlog is ready to use right out of the box, but it's possible to reconfigure default logger. Default logger is simple `Logger.new`. Add this code to `config/initializers/xlog.rb` and set any custom logger you want.
@@ -3,6 +3,7 @@
3
3
  require 'rails'
4
4
  require_relative 'xlog/xlogger'
5
5
  require_relative 'xlog/version'
6
+ require_relative 'xlog/middleware'
6
7
 
7
8
  module Xlog
8
9
  class << self
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xlog
4
+ class Middleware
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ @status, @headers, @response = @app.call(env)
11
+ rescue StandardError => e
12
+ Xlog.and_raise_error(e, data: { request_params: Rack::Request.new(env).params, status: @status, headers: @headers, response: @response })
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xlog
4
- VERSION = '0.1.3'.freeze
4
+ VERSION = '0.1.4'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - OrestF
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-04 00:00:00.000000000 Z
11
+ date: 2020-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,6 +76,7 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - README.md
78
78
  - lib/xlog.rb
79
+ - lib/xlog/middleware.rb
79
80
  - lib/xlog/version.rb
80
81
  - lib/xlog/xlogger.rb
81
82
  homepage: https://github.com/coaxsoft/xlog