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 +4 -4
- data/README.md +87 -10
- data/lib/log_error_handler/http_out.rb +3 -1
- data/lib/log_error_handler/stdin_reader.rb +3 -1
- data/lib/log_error_handler/version.rb +1 -1
- data/log_error_handler.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2485e96cdbdbfe4474f8bb35cd3f80f8f59eea23
|
4
|
+
data.tar.gz: e5c0b311f657aa1feb0c1b23d98ebc422d776727
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3128da7ed5b996314e2cb71363821506ab449e82806c37c8b5c04f8976dbbb4910e898d117a9fa917be9e6b9358ba814a026e025b74f5f7225f661b706550c79
|
7
|
+
data.tar.gz: bb5bcdbdf2565530cee44947d80b28fd3138e14bb1d46b2758cf2b275732f33156bda1e3f6e536f98a1323951efa5d9da03f1d57d8dd47ec3069879446c67e5a
|
data/README.md
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
# LogErrorHandler
|
2
2
|
|
3
|
-
|
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
|
+

|
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
|
-
|
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
|
-
|
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
|
-
|
30
|
-
|
31
|
-
To
|
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
|
+

|
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
|
+

|
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
|
+

|
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
|
+

|
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
|
+

|
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
|
+

|
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
|
+

|
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
|
+

|
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
|
+

|
100
|
+
|
101
|
+
Or:
|
102
|
+
|
103
|
+

|
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/
|
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)
|
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}"
|
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
|
data/log_error_handler.gemspec
CHANGED
@@ -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.
|
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-
|
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:
|