xlog 0.1.1 → 0.1.2

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: 9e093d33c6d4650e69e6319057c9f3c6d0657821c94fa339ec1fea3c0ba40dac
4
- data.tar.gz: 82bb2b2910223c9af42cf19a159673b7e46daa94c448f5c3c43457f8489a7e49
3
+ metadata.gz: 7ccd2436fed84277e65b847759e35046266a1863b4056fadfc01b85e751d3c2c
4
+ data.tar.gz: d386c7834e49faaffbcf23e0e1d32fdb7312583b6268cac18fd5028bbf286591
5
5
  SHA512:
6
- metadata.gz: cd086b221db39453401dd0bb5d1064cea47a6f747a3aa508f2a2060c497ffa3aefbb09b058491a2009f02bc1e86b0ff3998801c38306ce8be699009da9f272c6
7
- data.tar.gz: 3af328da784bc4f1f7c7278d4e4e07bc13e2c6094134476569f38cbe30e5ed497dbaa45f34fa2ea0fbc80d6b074823d198b9dbaad3c106dac3d537c466307d10
6
+ metadata.gz: fe55daec4b7ff8b3f33b05a59568d2c23bf2ccb52f142d2d2376965fe5821c3a6ea629a55f6e3f0cb5e15f0abf9220b4b7b9f954a3e387e74e00b97587b4b7c9
7
+ data.tar.gz: e80b2ff448b6da4446d8252236059b2bd36aed7fd5547086466a9f1d534e627b57253c455b9ab0282ada4ef8df95d6579d322c11be144de15b114fc0882ce8a5
data/README.md CHANGED
@@ -1,8 +1,69 @@
1
- # Xlog
1
+ # Xlog v0.0.1
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/xlog`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
5
+ ## Usage
6
+ Log any info with `.info` method
7
+ ```ruby
8
+ Xlog.info('Some info text') # [2019-04-30 12:29:13 UTC] [ArtilesController.show] [info] Message: Some info text
9
+ ```
10
+ Log important info with `.warn` method
11
+ ```ruby
12
+ Xlog.warn('Validation failed') # [2019-04-30 12:29:13 UTC] [ArticlesController.update] [warn] Message: Validation failed
13
+ ```
14
+
15
+ Xlog has awesome `.error` and `.and_raise_error` methods
16
+ ```ruby
17
+ def index
18
+ 10 / 0
19
+ @orders = Order.all
20
+ rescue StandardError => e
21
+ Xlog.and_raise_error(e, data: { params: params }, message: 'Some message text here')
22
+ end
23
+ ```
24
+ ...and the output
25
+ ```
26
+ [2019-04-30 11:48:33 UTC] [Admin::OrdersController.index] [error] ZeroDivisionError: divided by 0.
27
+ | Message: Some message text here
28
+ | Data: {:params=><ActionController::Parameters {"controller"=>"admin/orders", "action"=>"index"} permitted: false>}
29
+ | Error backtrace:
30
+ | /home/me/test_app/app/controllers/admin/orders_controller.rb:7:in `/'
31
+ | /home/me/test_app/app/controllers/admin/orders_controller.rb:7:in `index'
32
+ ```
33
+ The only difference between `Xlog.error` and `Xlog.and_raise_error` is that second one raises error after logging.
34
+
35
+ Xlog automatically defines Rails application name and environment.
36
+ It writes logs into `log/xlog_[environement].log`
37
+
38
+ Xlog also supports custom tags
39
+ ```ruby
40
+ Xlog.tag_logger('custom_tag')
41
+ Xlog.info('Some text') # [2019-04-30 12:29:13 UTC] [ArtilesController.show] [info] [custom_tag] Message: Some info text
42
+ ```
43
+
44
+ Clear tags with:
45
+ ```ruby
46
+ Xlog.clear_tags
47
+ ```
48
+
49
+ ## Configuration
50
+ 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.
51
+
52
+ ```ruby
53
+ Xlog.configure do |config|
54
+ config.custom_logger = Logger.new(STDOUT) # or Logger.new('foo.log', 10, 1024000) or any other
55
+ end
56
+ ```
57
+ It's possible to set third-party logger like Logentries(r7rapid)
58
+ ```ruby
59
+ require 'le'
60
+
61
+ Xlog.configure do |config|
62
+ config.custom_logger = Le.new(logentries_key, 'eu', tag: true)
63
+ end
64
+ ```
65
+
66
+ Look [here](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html) to know more about `Logger` configuration.
6
67
 
7
68
  ## Installation
8
69
 
@@ -20,10 +81,6 @@ Or install it yourself as:
20
81
 
21
82
  $ gem install xlog
22
83
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
84
  ## Development
28
85
 
29
86
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -32,7 +89,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
89
 
33
90
  ## Contributing
34
91
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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.
92
+ 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.
36
93
 
37
94
  ## License
38
95
 
@@ -40,4 +97,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
97
 
41
98
  ## Code of Conduct
42
99
 
43
- 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/[USERNAME]/xlog/blob/master/CODE_OF_CONDUCT.md).
100
+ 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).
101
+
102
+ ## Idea
103
+ Initially designed and created by [Orest Falchuk (OrestF)](https://github.com/OrestF)
data/lib/xlog/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xlog
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'.freeze
5
5
  end
data/lib/xlog/xlogger.rb CHANGED
@@ -17,6 +17,10 @@ module Xlog
17
17
  @tags = tags
18
18
  end
19
19
 
20
+ def clear_tags
21
+ @tags = nil
22
+ end
23
+
20
24
  def log(type, text)
21
25
  tags = [time_stamp, called_from(type), type] + Array.wrap(@tags)
22
26
  @base_logger.tagged(tags.compact) { @base_logger.send(type, text) }
data/lib/xlog.rb CHANGED
@@ -12,6 +12,10 @@ module Xlog
12
12
  config.xlogger.tag_logger(tags)
13
13
  end
14
14
 
15
+ def clear_tags
16
+ config.xlogger.clear_tags
17
+ end
18
+
15
19
  def info(message, data: nil)
16
20
  config.xlogger.info(message, data)
17
21
  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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OrestF
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-02 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,8 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Xlog is just awesome logger
69
+ description: Xlog - awesome logger for your Rails app. Logs everything you need in
70
+ well-formatted view with timestamp, caller path and tags.
70
71
  email:
71
72
  - falchuko@gmail.com
72
73
  executables: []
@@ -77,7 +78,7 @@ files:
77
78
  - lib/xlog.rb
78
79
  - lib/xlog/version.rb
79
80
  - lib/xlog/xlogger.rb
80
- homepage: https://github.com/OrestF/xlog
81
+ homepage: https://github.com/coaxsoft/xlog
81
82
  licenses:
82
83
  - MIT
83
84
  metadata: {}
@@ -99,5 +100,6 @@ requirements: []
99
100
  rubygems_version: 3.0.1
100
101
  signing_key:
101
102
  specification_version: 4
102
- summary: Xlog is just awesome logger
103
+ summary: Xlog - awesome logger for your Rails app. Logs everything you need in well-formatted
104
+ view with timestamp, caller path and tags.
103
105
  test_files: []