log_error_handler 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
  SHA1:
3
- metadata.gz: 73d834422224b75eca855fc6508be40a1f24aa3a
4
- data.tar.gz: 4a8923b446f270bedd70471880379f2d61739338
3
+ metadata.gz: 2485e96cdbdbfe4474f8bb35cd3f80f8f59eea23
4
+ data.tar.gz: e5c0b311f657aa1feb0c1b23d98ebc422d776727
5
5
  SHA512:
6
- metadata.gz: 213d9847baf05db31d49a9f51a1fc13b4a43ef5a3794d910f2ecc804ee4f50c5fcbd55a9e97c41e7c5c0bab50973e37d6302011e92acc0904369828c637eb7c9
7
- data.tar.gz: 16ea0f664c918e414f4a4e2e53dfa0232114c67d01d1bfd61d0489ffe282bdafd50713af90fc411f81fb1b9d52ed34cf64ebf4b9e2a7ce0fab03ded8144f8371
6
+ metadata.gz: 3128da7ed5b996314e2cb71363821506ab449e82806c37c8b5c04f8976dbbb4910e898d117a9fa917be9e6b9358ba814a026e025b74f5f7225f661b706550c79
7
+ data.tar.gz: bb5bcdbdf2565530cee44947d80b28fd3138e14bb1d46b2758cf2b275732f33156bda1e3f6e536f98a1323951efa5d9da03f1d57d8dd47ec3069879446c67e5a
data/README.md CHANGED
@@ -1,9 +1,7 @@
1
1
  # LogErrorHandler
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/log_error_handler`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
3
+ log_error_handler - it’s a gem for revealing and processing bugs in your server. Currently there are 3 variants of actions for bug revealing such as.: type in terminal, to write down in a separate document or send http request to the website. We’ll discuss about them in details a bit later.
4
+ ![image](https://cloud.githubusercontent.com/assets/20104771/26356962/84f12f4c-3fd6-11e7-925b-9cb3502d80dc.png)
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
@@ -22,15 +20,94 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ To make gem work , there should be a constant output data flow. You can do this in two ways:
24
+ 1. To lead pipe to gem, e.g
26
25
 
27
- ## Development
26
+ $ rails s | log_error_handler
27
+
28
+ This will ensure stdout of your program to stdin of gem. The minus of such an approach is that you can apply it only while launching your program which logs you want to track.
29
+
30
+ 2. To show the way to your log file to program,e.g:
28
31
 
29
- 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.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+ $ log_error_handler -l log/development.log
33
+
34
+ To output logs in a correct way gem needs a unique identification of each request to server .In case the majority of servers are multithreaded and each new request is elaborated in a new flow , so the best suit for this will be thread identificator (tid). To add this unique identifier, e.g in Ruby on Rails framework you need to add only one line:
35
+ ```ruby
36
+ config.log_tags = [:object_id]
37
+ ```
38
+ After this in each line of output logs tid is output. It looks like this:
39
+ ![image](https://cloud.githubusercontent.com/assets/20104771/26357965/a7c68aa0-3fd9-11e7-9249-dc0c6a0b6494.png)
32
40
 
41
+ To find tid gem uses regexp
42
+ ```ruby
43
+ /^\[\d+\]/
44
+ ```
45
+ But if the tid output way differs you can set it:
46
+
47
+ ![image](https://cloud.githubusercontent.com/assets/20104771/26358050/fc8febee-3fd9-11e7-8aec-67c1e0e9e6e7.png)
48
+
49
+ For example if tid is located in curly brackets and not at the start of the line:
50
+
51
+ $ log_error_handler -t /\\{\\d+\\}/
52
+ In case this regexp is written in terminal, we need double screen version.
53
+
54
+ Gem finds out that the request has an error when finds the line which corresponds to regexp of the error:
55
+ ![image](https://cloud.githubusercontent.com/assets/20104771/26358136/3cdeeda8-3fda-11e7-9a03-c6692653aa3c.png)
56
+
57
+ For example we need to catch not only error 500, but also 404:
58
+
59
+ $ log_error_handler -e "/(500)|(404).*error/i"
60
+
61
+ To look through values by default you need to type:
62
+ ![image](https://cloud.githubusercontent.com/assets/20104771/26358252/999fb3b0-3fda-11e7-886e-d5674a5fe103.png)
63
+ Time in settings by default is given in seconds.
64
+
65
+ Option `--not_modify_timeout` means time for thread to finish writing logs in this file, if timeout expires, and during this time file will not be changed at least once, so the file is sent to output, and if there are some errors it will be deleted.
66
+
67
+ Option `--log_file_tracker_waiting` means how often the checking cycle of temporary files in each thread will take place
68
+
69
+ Option `--debug_mode` provides the data output in stdout about reading from stdin.
70
+
71
+ As it was mentioned above there are 3 ways of data input:
72
+ 1. In stdout is performed by default, if none of the output parameters was indicated
73
+ 2. In the file if a parameter was indicated
74
+
75
+ ![image](https://cloud.githubusercontent.com/assets/20104771/26358415/2dfd67f0-3fdb-11e7-930e-ac6a80888e9e.png)
76
+
77
+ For example:
78
+
79
+ $ log_error_handler -f error.log
80
+ 3. Into the network. For this you need to indicate a parameter:
81
+    ![image](https://cloud.githubusercontent.com/assets/20104771/26358483/621b0eac-3fdb-11e7-870d-f3739a847842.png)
82
+
83
+ For example:
84
+
85
+ $ log_error_handler -u https://app.geteasyqa.com/projects/upload_crashes
86
+ http method post is used by default for data sending, but it can be easily replaced
87
+ ![image](https://cloud.githubusercontent.com/assets/20104771/26358600/aece1ce4-3fdb-11e7-85d9-d6d399a153fc.png)
88
+
89
+ For example:
90
+
91
+ $ log_error_handler -u https://app.geteasyqa.com/projects/upload_crashes -m put
92
+ Message is a key by default, under which error is located , so parameter is responsible for this value
93
+    ![image](https://cloud.githubusercontent.com/assets/20104771/26358654/dc1950d8-3fdb-11e7-8669-dc3def2520bf.png)
94
+
95
+ For example:
96
+
97
+ $ log_error_handler -u https://app.geteasyqa.com/projects/upload_crashes -m put -k error
98
+ If you need to send some additional parameters with an error so you can set them by means of options such as:
99
+ ![image](https://cloud.githubusercontent.com/assets/20104771/26358699/000362cc-3fdc-11e7-9ae7-1b84dc75ebc6.png)
100
+
101
+ Or:
102
+
103
+ ![image](https://cloud.githubusercontent.com/assets/20104771/26359053/1b09d1ae-3fdd-11e7-97be-10a66558e387.png)
104
+
105
+ For example:
106
+
107
+ $ log_error_handler -u https://app.geteasyqa.com/projects/upload_crashes -m put -k error -a "{\"token\":\"uQF7ZYtHh9VDMXBaJojq\"}"
108
+ Before sending all errors are encoded in Base64
109
+
33
110
  ## Contributing
34
111
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/log_error_handler. 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.
112
+ Bug reports and pull requests are welcome on GitHub at https://github.com/thinkmobiles/log_error_handler. 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
113
 
@@ -9,7 +9,9 @@ module LogErrorHandler
9
9
  data = @options[:additional_params] || {}
10
10
  data[@options[:error_message_key]] = Base64.encode64(message)
11
11
  @req.set_form_data(data)
12
- Net::HTTP.new(@options[:uri].hostname, @options[:uri].port).request(@req)
12
+ http = Net::HTTP.new(@options[:uri].hostname, @options[:uri].port)
13
+ http.use_ssl = @options[:uri].scheme == 'https'
14
+ http.request(@req)
13
15
  end
14
16
 
15
17
  def close
@@ -14,6 +14,7 @@ module LogErrorHandler
14
14
 
15
15
  def start
16
16
  Dir.mkdir("/tmp/#{TMP_DIR_NAME}") unless Dir.exist?("/tmp/#{TMP_DIR_NAME}")
17
+ $stdout.puts 'Starting read input data...' if @tracker.options[:debug_mode]
17
18
  $stdin.each do |line|
18
19
  tid = line[@tracker.options[:tid_regexp]]
19
20
  @last_tid = tid || @last_tid
@@ -24,6 +25,7 @@ module LogErrorHandler
24
25
  private
25
26
 
26
27
  def write_to_file(line)
28
+ $stdout.puts 'Starting write to file' if @tracker.options[:debug_mode]
27
29
  @tracker.mutex.lock
28
30
  @tracker.tracking_logs[@last_tid] ||= {
29
31
  file: Tempfile.new("log_error_handler/#{@last_tid}"),
@@ -33,7 +35,7 @@ module LogErrorHandler
33
35
  @tracker.mutex.unlock
34
36
 
35
37
  text = line.sub(@tracker.options[:tid_regexp], '')
36
- $stdout.puts "#{@last_tid}: #{text}" if @tracker.options[:debug_mode]
38
+ $stdout.puts "#{@last_tid}: #{text}" if @tracker.options[:debug_mode]
37
39
  @tracker.tracking_logs[@last_tid][:file].write(text)
38
40
  @tracker.tracking_logs[@last_tid][:status] = :error if text[@tracker.options[:error_regexp]]
39
41
  @tracker.tracking_logs[@last_tid][:timestamp] = Time.now.to_i
@@ -1,3 +1,3 @@
1
1
  module LogErrorHandler
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = LogErrorHandler::VERSION
9
9
  spec.authors = ['Thinkmobiles']
10
10
  spec.email = ['gashuk95@gmail.com']
11
-
11
+ spec.license = 'MIT'
12
12
  spec.summary = 'Gem for notification when logs have any errors.'
13
13
  spec.description = 'Simple gem for server error notification. This gem use only logfile, and not depends on any languages'
14
14
  spec.homepage = 'https://github.com/thinkmobiles/log_error_handler'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_error_handler
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
  - Thinkmobiles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,7 +94,8 @@ files:
94
94
  - lib/log_error_handler/version.rb
95
95
  - log_error_handler.gemspec
96
96
  homepage: https://github.com/thinkmobiles/log_error_handler
97
- licenses: []
97
+ licenses:
98
+ - MIT
98
99
  metadata:
99
100
  allowed_push_host: https://rubygems.org
100
101
  post_install_message: