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 CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.join(dir, 'lib', 'le'))
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "le"
6
- s.version = "1.9.2"
6
+ s.version = "2.0"
7
7
  s.date = Time.now
8
8
  s.summary = "Logentries plugin"
9
9
  s.description =<<EOD
data/lib/le.rb CHANGED
@@ -13,11 +13,11 @@ require 'logger'
13
13
 
14
14
  module Le
15
15
 
16
- def self.new(key, location, local=false)
16
+ def self.new(token, local=false)
17
17
 
18
- self.checkParams(key, location)
18
+ self.checkParams(token)
19
19
 
20
- host = Le::Host.new(key, location, local)
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(key, location)
29
- if key == nil or location == nil
30
- puts "\nLE: Incorrect parameters for Logentries Plugin!\n"
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 (key =~ /\A(urn:uuid:)?[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i) == nil
35
- puts "\nLE: It appears the LOGENTRIES_ACCOUNT_KEY you entered is invalid!\n"
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
@@ -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(key, location, local)
16
+ def self.new(token, local)
17
17
 
18
- Le::Host::HTTPS.new(key, location, local)
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
- msg_out << msg_in.inspect
42
- end
40
+ msg_out << msg_in.inspect
41
+ end
43
42
  msg_out
44
43
  end
45
44
  end
@@ -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(key, location, local)
19
+ def initialize(token, local)
23
20
  @local_bool = local
24
21
  if not local
25
- @deliverer = Le::Host::HTTPS::TCPSOCKET.new(key, location)
22
+ @deliverer = Le::Host::HTTPS::TCPSOCKET.new(token)
26
23
  end
27
24
  end
28
25
 
@@ -7,39 +7,30 @@
7
7
  # Mark Lacomber <marklacomber@gmail.com>
8
8
  #
9
9
 
10
- require 'uri'
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 :sock, :conn, :key, :location
18
- def initialize(key, location)
19
+ attr_accessor :conn, :token
20
+ def initialize(token)
19
21
 
20
- @key = key
21
- @location = URI::encode(location)
22
+ @token = token
22
23
  begin
23
- createSocket(@key, @location)
24
- rescue OpenSSL::SSL::SSLError, TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
25
- $stderr.puts "WARNING: #{e.class} creating the connection to Logentries. #{e.message}"
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(key, location)
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
- @sock = TCPSocket.new('api.logentries.com', 443)
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(@key, @location)
51
- rescue OpenSSL::SSL::SSLError, TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
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.print(message + "\r\n")
59
- rescue OpenSSL::SSL::SSLError, TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ENOTCONN, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
60
- $stderr.puts "WARNING: #{e.class} sending log #{e.message}"
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(@key, @location)
63
- rescue OpenSSL::SSL::SSLError, TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
64
- $stderr.puts "WARNING: #{e.class} creating the connection to Logentries. #{e.message}"
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
- hash: 55
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
- description: |
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
- hash: 3
51
- segments:
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
- hash: 3
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.15
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
-