xlog 0.1.0 → 0.1.5
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 +27 -3
- data/lib/xlog.rb +7 -2
- data/lib/xlog/middleware.rb +15 -0
- data/lib/xlog/version.rb +1 -1
- data/lib/xlog/xlogger.rb +4 -0
- metadata +27 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d164bebc098c5c7b0dbe424397856e92011a53648273d4e8609b5f112d2db9ff
|
4
|
+
data.tar.gz: c8f0cc3eabb68d96bc60dfa12d5a598fe071d7a72de5c53141284254d99dfe56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e14895a0d31c8db2a23a3b9745d1b43e8230d26f70ac955c64f0da3adcfd188501233ecfd57c9019f9e864203e07edc053803b2ef79b9e4e4a5538d8fa8b28dc
|
7
|
+
data.tar.gz: 69765e968d5a89352cc9ce5fe5f4fd4dfd9a8c610063224b5f738305a39a11b0f9bbc8d01eadfd8821cded84a474afc3ac63d79871c059b127fc31c9105dba29
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
# Xlog v0.
|
1
|
+
# Xlog v0.1.5
|
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
|
@@ -35,6 +36,29 @@ The only difference between `Xlog.error` and `Xlog.and_raise_error` is that seco
|
|
35
36
|
Xlog automatically defines Rails application name and environment.
|
36
37
|
It writes logs into `log/xlog_[environement].log`
|
37
38
|
|
39
|
+
Xlog also supports custom tags
|
40
|
+
```ruby
|
41
|
+
Xlog.tag_logger('custom_tag')
|
42
|
+
Xlog.info('Some text') # [2019-04-30 12:29:13 UTC] [ArtilesController.show] [info] [custom_tag] Message: Some info text
|
43
|
+
```
|
44
|
+
|
45
|
+
Clear tags with:
|
46
|
+
```ruby
|
47
|
+
Xlog.clear_tags
|
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
|
+
```
|
61
|
+
|
38
62
|
## Configuration
|
39
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.
|
40
64
|
|
@@ -78,7 +102,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
78
102
|
|
79
103
|
## Contributing
|
80
104
|
|
81
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
105
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/coaxsoft/xlog. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
82
106
|
|
83
107
|
## License
|
84
108
|
|
@@ -86,7 +110,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
86
110
|
|
87
111
|
## Code of Conduct
|
88
112
|
|
89
|
-
Everyone interacting in the Xlog project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
113
|
+
Everyone interacting in the Xlog project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/coaxsoft/xlog/blob/master/CODE_OF_CONDUCT.md).
|
90
114
|
|
91
115
|
## Idea
|
92
116
|
Initially designed and created by [Orest Falchuk (OrestF)](https://github.com/OrestF)
|
data/lib/xlog.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rails'
|
4
|
-
|
5
|
-
|
4
|
+
require_relative 'xlog/xlogger'
|
5
|
+
require_relative 'xlog/version'
|
6
|
+
require_relative 'xlog/middleware'
|
6
7
|
|
7
8
|
module Xlog
|
8
9
|
class << self
|
@@ -12,6 +13,10 @@ module Xlog
|
|
12
13
|
config.xlogger.tag_logger(tags)
|
13
14
|
end
|
14
15
|
|
16
|
+
def clear_tags
|
17
|
+
config.xlogger.clear_tags
|
18
|
+
end
|
19
|
+
|
15
20
|
def info(message, data: nil)
|
16
21
|
config.xlogger.info(message, data)
|
17
22
|
end
|
@@ -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
data/lib/xlog/xlogger.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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OrestF
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.1.4
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,22 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Xlog - awesome logger for your Rails app. Logs everything you need in
|
84
|
+
well-formatted view with timestamp, caller path and tags.
|
70
85
|
email:
|
71
86
|
- falchuko@gmail.com
|
72
87
|
executables: []
|
@@ -75,9 +90,10 @@ extra_rdoc_files: []
|
|
75
90
|
files:
|
76
91
|
- README.md
|
77
92
|
- lib/xlog.rb
|
93
|
+
- lib/xlog/middleware.rb
|
78
94
|
- lib/xlog/version.rb
|
79
95
|
- lib/xlog/xlogger.rb
|
80
|
-
homepage: https://github.com/
|
96
|
+
homepage: https://github.com/coaxsoft/xlog
|
81
97
|
licenses:
|
82
98
|
- MIT
|
83
99
|
metadata: {}
|
@@ -96,8 +112,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
112
|
- !ruby/object:Gem::Version
|
97
113
|
version: '0'
|
98
114
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
115
|
+
rubygems_version: 3.1.2
|
100
116
|
signing_key:
|
101
117
|
specification_version: 4
|
102
|
-
summary: Xlog
|
118
|
+
summary: Xlog - awesome logger for your Rails app. Logs everything you need in well-formatted
|
119
|
+
view with timestamp, caller path and tags.
|
103
120
|
test_files: []
|