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 +4 -4
- data/README.md +14 -1
- data/lib/xlog.rb +1 -0
- data/lib/xlog/middleware.rb +15 -0
- data/lib/xlog/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5175ddef67a168d0ba5a200ddeb9efdc88dcdd98ccedd615ad26b2bedd2c3ef3
|
4
|
+
data.tar.gz: e150396dd1caaced0ddefc4e34c48cb5e2868985bb615b1671718a4dc6fe4600
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5ee9f1686a38080d1f9b20c51013032ac4d3fc1c46e6e0b9a8c1dcd3ee20279fa3dda20ba7c1f5365f4e62f9b33fa03913ac50440e91f55e84ea6e7684629e3
|
7
|
+
data.tar.gz: bbb8f13f909d632a78377a6618c93984549a48c75526bbf73293ebcb49bf5af90c52e1183109ab4ba3ca70282fc579d2fc895286e6750e830e4c325fb551a737
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
# Xlog v0.1.
|
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.
|
data/lib/xlog.rb
CHANGED
@@ -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
|
data/lib/xlog/version.rb
CHANGED
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.
|
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-
|
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
|