elasticelmah 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/elasticelmah.rb CHANGED
@@ -33,7 +33,7 @@ module ElasticElmah
33
33
  Logger.log_internal {"Outputter '#{@name}' closed and set to OFF"}
34
34
  end
35
35
 
36
- def serialize(l)
36
+ def serialize_logevent_for_elastic(l)
37
37
  # attr_reader :level, :tracer, :data, :name, :fullname
38
38
  # [level] The integer level of the log event. Use LNAMES[level]
39
39
  # to get the actual level name.
@@ -125,7 +125,7 @@ module ElasticElmah
125
125
  create_index
126
126
  end
127
127
  end
128
- @client.index index: @index, type: 'LoggingEvent', body: serialize(logevent)
128
+ @client.index index: @index, type: 'LoggingEvent', body: serialize_logevent_for_elastic(logevent)
129
129
  end
130
130
  end
131
131
  end
@@ -47,6 +47,19 @@ class TestElasticElmahOutputterForReal < Test::Unit::TestCase
47
47
  hits = result["hits"]["hits"]
48
48
  assert_equal 'some_error', hits[0]["_source"]["message"]
49
49
  end
50
+
51
+ def test_generated_from_logging_event_data
52
+ begin
53
+ raise 'some_error'
54
+ rescue Exception => e
55
+ @logger.error(e)
56
+ end
57
+ @client.indices.flush(index: @index )
58
+ result = @client.search index: @index
59
+ assert_equal 1, result["hits"]["hits"].length
60
+ hits = result["hits"]["hits"]
61
+ assert_equal 'some_error', hits[0]["_source"]["message"]
62
+ end
50
63
  end
51
64
 
52
65
 
@@ -73,7 +86,7 @@ class TestElasticElmahOutputter < Test::Unit::TestCase
73
86
  :exceptionString=>"",
74
87
  :domain=>"",
75
88
  :identity=>""}],
76
- @outp.written.map do |written| @outp.serialize(written) end)
89
+ @outp.written.map do |written| @outp.serialize_logevent_for_elastic(written) end)
77
90
  end
78
91
  end
79
92
 
@@ -96,7 +109,7 @@ class TestElasticElmahSerializer < Test::Unit::TestCase
96
109
  tracer = caller
97
110
  data = Exception.new("Message")
98
111
  l = Log4r::LogEvent.new(Log4r::INFO, logger, tracer, data)
99
- s = @outp.serialize(l)
112
+ s = @outp.serialize_logevent_for_elastic(l)
100
113
  assert_equal("Message",s[:message])
101
114
  assert_equal(caller.join("\n"),s[:exceptionString])
102
115
  end
@@ -124,6 +137,6 @@ class TestElasticElmahSerializer < Test::Unit::TestCase
124
137
  tracer = nil
125
138
  data = Exception.new("Message")
126
139
  l = Log4r::LogEvent.new(Log4r::INFO, logger, tracer, data)
127
- assert_equal(expected, @outp.serialize(l))
140
+ assert_equal(expected, @outp.serialize_logevent_for_elastic(l))
128
141
  end
129
142
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticelmah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: