le 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
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 = "2.1.3"
6
+ s.version = "2.1.4"
7
7
  s.date = Time.now
8
8
  s.summary = "Logentries plugin"
9
9
  s.description =<<EOD
data/lib/le.rb CHANGED
@@ -4,13 +4,13 @@ require 'logger'
4
4
 
5
5
  module Le
6
6
 
7
- def self.new(token, local=false)
7
+ def self.new(token, local=false, debug_level = Logger::DEBUG)
8
8
 
9
9
  self.checkParams(token)
10
10
 
11
11
  host = Le::Host.new(token, local)
12
12
  logger = Logger.new(host)
13
- logger.level = Logger::DEBUG
13
+ logger.level = debug_level
14
14
 
15
15
  if host.respond_to?(:formatter)
16
16
  logger.formatter = host.formatter
data/lib/le/host.rb CHANGED
@@ -2,33 +2,24 @@ module Le
2
2
  module Host
3
3
 
4
4
  def self.new(token, local)
5
-
6
5
  Le::Host::HTTP.new(token, local)
7
-
8
6
  end
9
-
7
+
10
8
  module InstanceMethods
11
9
  def formatter
12
- proc do |severity, datetime, progname, msg|
13
- message = "#{datetime} "
14
- message << format_message(msg, severity)
15
- end
16
- end
17
-
10
+ proc do |severity, datetime, _, msg|
11
+ message = "#{datetime} "
12
+ message << format_message(msg, severity)
13
+ end
14
+ end
15
+
18
16
  def format_message(message_in, severity)
19
- message_in = message_in.lstrip
17
+ message_in = message_in.inspect unless message_in.is_a?(String)
20
18
 
21
- message_out = ""
22
- message_out = "severity=#{severity}, "
23
- case message_in
24
- when String
25
- message_out << message_in
26
- else
27
- message_out << message_in.inspect
28
- end
29
- message_out
19
+ "severity=#{severity}, #{message_in.lstrip}"
30
20
  end
31
21
  end
22
+
32
23
  end
33
24
  end
34
25
 
data/lib/le/host/http.rb CHANGED
@@ -10,6 +10,11 @@ module Le
10
10
  attr_accessor :token, :queue, :started, :thread, :conn, :local
11
11
 
12
12
  def initialize(token, local)
13
+ if defined?(Rails)
14
+ @logger_console = Logger.new("log/#{Rails.env}.log")
15
+ else
16
+ @logger_console = Logger.new(STDOUT);
17
+ end
13
18
  @token = token
14
19
  @local = local
15
20
  @queue = Queue.new
@@ -19,8 +24,7 @@ module Le
19
24
 
20
25
  def write(message)
21
26
  if @local then
22
- puts message
23
- return
27
+ @logger_console.add(Logger::Severity::UNKNOWN,message)
24
28
  end
25
29
 
26
30
  @queue << "#{@token}#{message}\n"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: le
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-08 00:00:00.000000000 Z
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! '
15
15
 
@@ -43,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  version: '0'
44
44
  requirements: []
45
45
  rubyforge_project:
46
- rubygems_version: 1.8.11
46
+ rubygems_version: 1.8.23
47
47
  signing_key:
48
48
  specification_version: 3
49
49
  summary: Logentries plugin