Http_Error_Log 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -25,10 +25,13 @@ Usage
25
25
 
26
26
  Each Hash object has:
27
27
 
28
- :line => 12 # Integer
29
28
  :created_at => Time.parse(str) # Time object.
30
- :backtrace => [ "file:num:[error] 11563#0"]
31
- :message => "*183 connect() failed (111: Connection refused) while connecting to upstream"
29
+ :msg => "*183 connect() failed (111: Connection refused) while connecting to upstream"
30
+ :error => "[error] 11563#0"
31
+ :line => 5 # line number in file
32
+
33
+ # plus the other fiends in the file:
34
+ # :upstream, :server, :request, etc.
32
35
 
33
36
  Skip records using a date/time string:
34
37
 
@@ -4,11 +4,11 @@ require 'time'
4
4
 
5
5
  def Http_Error_Log file, skip = nil
6
6
  h = Http_Error_Log_Helper
7
-
7
+ count = 0
8
8
  lines = Split_Lines(File.read( file ))
9
9
  lines
10
10
  .map { |l|
11
-
11
+ count += 1
12
12
  pieces = l.split %r!,?\s+([\w\_\.\-]+):\s+!
13
13
 
14
14
  prefix = pieces.shift
@@ -24,6 +24,7 @@ def Http_Error_Log file, skip = nil
24
24
 
25
25
  final = Hash[ *pieces ]
26
26
  final[:created_at], final[:error], final[:msg] = h.to_time(prefix)
27
+ final[:line] = count
27
28
 
28
29
  final
29
30
 
@@ -53,9 +54,11 @@ class Http_Error_Log_Helper
53
54
  date = pieces.shift
54
55
  time = pieces.shift
55
56
 
56
- err, msg = pieces.join(' ').split(':')
57
+ raw_err = pieces.join(' ').split(':')
58
+ err = raw_err.shift
59
+ msg = raw_err.join(':')
57
60
 
58
- [ Time.parse("#{date} #{time}" ), err, msg]
61
+ [ Time.parse("#{date} #{time}" ), err.strip, msg.strip]
59
62
  end
60
63
 
61
64
  end # === << self
@@ -1 +1 @@
1
- Http_Error_Log_VERSION = "0.1.0"
1
+ Http_Error_Log_VERSION = "0.1.1"
@@ -37,12 +37,24 @@ describe "Http_Error_Log 'file'" do
37
37
  it "sets key: :referrer" do
38
38
  key_should_be :referrer, '"http://www.test.com/"'
39
39
  end
40
-
41
40
 
42
- it "sets key: upstream" do
41
+ it "sets key: :upstream" do
43
42
  key_should_be :upstream, "http://127.0.0.1:4567/test/en-us/Test-Page.css?time=1234.5678".inspect
44
43
  end
45
44
 
45
+ it "sets key: :line" do
46
+ key_should_be :line, 1
47
+ NGINX_ERROR_LOG[1][:line]
48
+ .should == 2
49
+ end
50
+
51
+ it "sets key: :msg" do
52
+ key_should_be :msg, "*183 connect() failed (111: Connection refused) while connecting to upstream"
53
+ end
54
+
55
+ it "sets key: :error" do
56
+ key_should_be :error, "[error] 11563#0"
57
+ end
46
58
 
47
59
  it "returns an empty array if file is empty" do
48
60
  EMPTY_LOG
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Http_Error_Log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: