le 1.9.2 → 2.0
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.
- data/LE.gemspec +1 -1
- data/lib/le.rb +8 -8
- data/lib/le/host.rb +4 -5
- data/lib/le/host/https.rb +2 -5
- data/lib/le/host/https/tcp.rb +19 -28
- metadata +22 -42
data/LE.gemspec
CHANGED
data/lib/le.rb
CHANGED
@@ -13,11 +13,11 @@ require 'logger'
|
|
13
13
|
|
14
14
|
module Le
|
15
15
|
|
16
|
-
def self.new(
|
16
|
+
def self.new(token, local=false)
|
17
17
|
|
18
|
-
self.checkParams(
|
18
|
+
self.checkParams(token)
|
19
19
|
|
20
|
-
host = Le::Host.new(
|
20
|
+
host = Le::Host.new(token, local)
|
21
21
|
logger = Logger.new(host)
|
22
22
|
|
23
23
|
logger.formatter = host.formatter
|
@@ -25,14 +25,14 @@ module Le
|
|
25
25
|
logger
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.checkParams(
|
29
|
-
if
|
30
|
-
puts "\nLE: Incorrect
|
28
|
+
def self.checkParams(token)
|
29
|
+
if token == nil
|
30
|
+
puts "\nLE: Incorrect token parameter for Logentries Plugin!\n"
|
31
31
|
end
|
32
32
|
|
33
33
|
# Check if the key is valid UUID format
|
34
|
-
if (
|
35
|
-
puts "\nLE: It appears the
|
34
|
+
if (token =~ /\A(urn:uuid:)?[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i) == nil
|
35
|
+
puts "\nLE: It appears the LOGENTRIES_TOKEN you entered is invalid!\n"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/le/host.rb
CHANGED
@@ -13,9 +13,9 @@ module Le
|
|
13
13
|
# Creates a new Logentries host, based on a user-key and location of destination file on logentries,
|
14
14
|
# both must be provided correctly for a connection to be made.
|
15
15
|
|
16
|
-
def self.new(
|
16
|
+
def self.new(token, local)
|
17
17
|
|
18
|
-
Le::Host::HTTPS.new(
|
18
|
+
Le::Host::HTTPS.new(token, local)
|
19
19
|
|
20
20
|
end
|
21
21
|
|
@@ -30,7 +30,6 @@ module Le
|
|
30
30
|
|
31
31
|
def format_message(msg_in, severity)
|
32
32
|
msg_in = msg_in.lstrip
|
33
|
-
|
34
33
|
msg_out = ""
|
35
34
|
msg_out << "severity=#{severity}, "
|
36
35
|
|
@@ -38,8 +37,8 @@ module Le
|
|
38
37
|
when String
|
39
38
|
msg_out << msg_in
|
40
39
|
else
|
41
|
-
|
42
|
-
|
40
|
+
msg_out << msg_in.inspect
|
41
|
+
end
|
43
42
|
msg_out
|
44
43
|
end
|
45
44
|
end
|
data/lib/le/host/https.rb
CHANGED
@@ -7,9 +7,6 @@
|
|
7
7
|
# Mark Lacomber <marklacomber@gmail.com>
|
8
8
|
#
|
9
9
|
|
10
|
-
require 'socket'
|
11
|
-
require 'openssl'
|
12
|
-
|
13
10
|
require File.join(File.dirname(__FILE__), 'https', 'tcp')
|
14
11
|
|
15
12
|
module Le
|
@@ -19,10 +16,10 @@ module Le
|
|
19
16
|
|
20
17
|
attr_reader :deliverer, :local_bool
|
21
18
|
|
22
|
-
def initialize(
|
19
|
+
def initialize(token, local)
|
23
20
|
@local_bool = local
|
24
21
|
if not local
|
25
|
-
@deliverer = Le::Host::HTTPS::TCPSOCKET.new(
|
22
|
+
@deliverer = Le::Host::HTTPS::TCPSOCKET.new(token)
|
26
23
|
end
|
27
24
|
end
|
28
25
|
|
data/lib/le/host/https/tcp.rb
CHANGED
@@ -7,39 +7,30 @@
|
|
7
7
|
# Mark Lacomber <marklacomber@gmail.com>
|
8
8
|
#
|
9
9
|
|
10
|
-
require '
|
10
|
+
require 'socket'
|
11
|
+
require 'openssl'
|
11
12
|
|
12
13
|
module Le
|
13
14
|
module Host
|
14
15
|
class HTTPS
|
16
|
+
|
15
17
|
class TCPSOCKET
|
16
18
|
|
17
|
-
attr_accessor :
|
18
|
-
def initialize(
|
19
|
+
attr_accessor :conn, :token
|
20
|
+
def initialize(token)
|
19
21
|
|
20
|
-
@
|
21
|
-
@location = URI::encode(location)
|
22
|
+
@token = token
|
22
23
|
begin
|
23
|
-
createSocket(
|
24
|
-
rescue
|
25
|
-
$stderr.puts "WARNING: #{e.class}
|
24
|
+
createSocket()
|
25
|
+
rescue TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
|
26
|
+
$stderr.puts "WARNING: #{e.class} Could not create the connection to Logentries. #{e.message}"
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
def createSocket(
|
30
|
-
|
31
|
-
addr = sprintf('/%s/hosts/%s/?realtime=1', key, location)
|
30
|
+
def createSocket()
|
32
31
|
|
33
32
|
# Open the TCP connection to the Logentries Server
|
34
|
-
@
|
35
|
-
|
36
|
-
@conn = OpenSSL::SSL::SSLSocket.new(@sock, OpenSSL::SSL::SSLContext.new())
|
37
|
-
@conn.sync_close = true
|
38
|
-
@conn.connect
|
39
|
-
|
40
|
-
# Set up connection with Logentries API to receive messages in chunks, i.e, logs
|
41
|
-
request = sprintf("PUT %s HTTP/1.1\r\n\r\n", addr)
|
42
|
-
@conn.write(request)
|
33
|
+
@conn = TCPSocket.new('api.logentries.com', 10000)
|
43
34
|
|
44
35
|
end
|
45
36
|
|
@@ -47,21 +38,21 @@ module Le
|
|
47
38
|
|
48
39
|
if @conn == nil
|
49
40
|
begin
|
50
|
-
createSocket(
|
51
|
-
rescue
|
41
|
+
createSocket()
|
42
|
+
rescue TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
|
52
43
|
$stderr.puts "WARNING: #{e.class} Could not write log. No connection to Logentries #{e.message}"
|
53
44
|
return
|
54
45
|
end
|
55
46
|
end
|
56
47
|
# Sends the log to the Logentries Server
|
57
48
|
begin
|
58
|
-
@conn.
|
59
|
-
rescue
|
60
|
-
$stderr.puts "WARNING: #{e.class}
|
49
|
+
@conn.puts(@token + message)
|
50
|
+
rescue TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ENOTCONN, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
|
51
|
+
$stderr.puts "WARNING: #{e.class} Could not send log to Logentries #{e.message}"
|
61
52
|
begin
|
62
|
-
createSocket(
|
63
|
-
rescue
|
64
|
-
$stderr.puts "WARNING: #{e.class}
|
53
|
+
createSocket()
|
54
|
+
rescue TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
|
55
|
+
$stderr.puts "WARNING: #{e.class} Could not create the connection to Logentries. #{e.message}"
|
65
56
|
end
|
66
57
|
end
|
67
58
|
end
|
metadata
CHANGED
@@ -1,71 +1,51 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: le
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '2.0'
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 9
|
9
|
-
- 2
|
10
|
-
version: 1.9.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Mark Lacomber (Logentries)
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2012-07-26 00:00:00 Z
|
12
|
+
date: 2012-09-28 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
14
|
+
description: ! '
|
20
15
|
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
'
|
24
17
|
email: marklacomber@gmail.com
|
25
18
|
executables: []
|
26
|
-
|
27
19
|
extensions: []
|
28
|
-
|
29
20
|
extra_rdoc_files: []
|
30
|
-
|
31
|
-
files:
|
21
|
+
files:
|
32
22
|
- LE.gemspec
|
23
|
+
- ./lib/le.rb
|
33
24
|
- ./lib/le/host.rb
|
34
|
-
- ./lib/le/host/https/tcp.rb
|
35
25
|
- ./lib/le/host/https.rb
|
36
|
-
- ./lib/le.rb
|
26
|
+
- ./lib/le/host/https/tcp.rb
|
37
27
|
homepage:
|
38
28
|
licenses: []
|
39
|
-
|
40
29
|
post_install_message:
|
41
30
|
rdoc_options: []
|
42
|
-
|
43
|
-
require_paths:
|
31
|
+
require_paths:
|
44
32
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
34
|
none: false
|
47
|
-
requirements:
|
48
|
-
- -
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
|
51
|
-
|
52
|
-
- 0
|
53
|
-
version: "0"
|
54
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
40
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
version: "0"
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
63
45
|
requirements: []
|
64
|
-
|
65
46
|
rubyforge_project:
|
66
|
-
rubygems_version: 1.8.
|
47
|
+
rubygems_version: 1.8.11
|
67
48
|
signing_key:
|
68
49
|
specification_version: 3
|
69
50
|
summary: Logentries plugin
|
70
51
|
test_files: []
|
71
|
-
|