fluent-plugin-windows-eventlog 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,47 +1,47 @@
1
- require 'win32/eventlog'
2
-
3
- class EventLog
4
- def initialize
5
- @logger = Win32::EventLog.new
6
- @app_source = "fluent-plugins"
7
- end
8
-
9
- def info(event_id, message)
10
- @logger.report_event(
11
- source: @app_source,
12
- event_type: Win32::EventLog::INFO_TYPE,
13
- event_id: event_id,
14
- data: message
15
- )
16
- end
17
-
18
- def warn(event_id, message)
19
- @logger.report_event(
20
- source: @app_source,
21
- event_type: Win32::EventLog::WARN_TYPE,
22
- event_id: event_id,
23
- data: message
24
- )
25
- end
26
-
27
- def crit(event_id, message)
28
- @logger.report_event(
29
- source: @app_source,
30
- event_type: Win32::EventLog::ERROR_TYPE,
31
- event_id: event_id,
32
- data: message
33
- )
34
- end
35
-
36
- end
37
-
38
- module Fluent
39
- module Plugin
40
- class EventService
41
- def run
42
- eventlog = EventLog.new()
43
- eventlog.info(65500, "Hi, from fluentd-plugins!! at " + Time.now.strftime("%Y/%m/%d %H:%M:%S "))
44
- end
45
- end
46
- end
47
- end
1
+ require 'win32/eventlog'
2
+
3
+ class EventLog
4
+ def initialize
5
+ @logger = Win32::EventLog.new
6
+ @app_source = "fluent-plugins"
7
+ end
8
+
9
+ def info(event_id, message)
10
+ @logger.report_event(
11
+ source: @app_source,
12
+ event_type: Win32::EventLog::INFO_TYPE,
13
+ event_id: event_id,
14
+ data: message
15
+ )
16
+ end
17
+
18
+ def warn(event_id, message)
19
+ @logger.report_event(
20
+ source: @app_source,
21
+ event_type: Win32::EventLog::WARN_TYPE,
22
+ event_id: event_id,
23
+ data: message
24
+ )
25
+ end
26
+
27
+ def crit(event_id, message)
28
+ @logger.report_event(
29
+ source: @app_source,
30
+ event_type: Win32::EventLog::ERROR_TYPE,
31
+ event_id: event_id,
32
+ data: message
33
+ )
34
+ end
35
+
36
+ end
37
+
38
+ module Fluent
39
+ module Plugin
40
+ class EventService
41
+ def run
42
+ eventlog = EventLog.new()
43
+ eventlog.info(65500, "Hi, from fluentd-plugins!! at " + Time.now.strftime("%Y/%m/%d %H:%M:%S "))
44
+ end
45
+ end
46
+ end
47
+ end
data/test/helper.rb CHANGED
@@ -1,34 +1,34 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
-
12
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
- $LOAD_PATH.unshift(File.dirname(__FILE__))
14
- require 'fluent/test'
15
- unless ENV.has_key?('VERBOSE')
16
- nulllogger = Object.new
17
- nulllogger.instance_eval {|obj|
18
- def method_missing(method, *args)
19
- # pass
20
- end
21
- }
22
- $log = nulllogger
23
- end
24
-
25
- require 'fluent/test/driver/input'
26
- require 'fluent/plugin/in_windows_eventlog'
27
- require 'fluent/plugin/in_windows_eventlog2'
28
- require 'fluent/plugin/bookmark_sax_parser'
29
-
30
- class Test::Unit::TestCase
31
- end
32
- require 'fluent/test/helpers'
33
-
34
- include Fluent::Test::Helpers
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+ require 'fluent/test'
15
+ unless ENV.has_key?('VERBOSE')
16
+ nulllogger = Object.new
17
+ nulllogger.instance_eval {|obj|
18
+ def method_missing(method, *args)
19
+ # pass
20
+ end
21
+ }
22
+ $log = nulllogger
23
+ end
24
+
25
+ require 'fluent/test/driver/input'
26
+ require 'fluent/plugin/in_windows_eventlog'
27
+ require 'fluent/plugin/in_windows_eventlog2'
28
+ require 'fluent/plugin/bookmark_sax_parser'
29
+
30
+ class Test::Unit::TestCase
31
+ end
32
+ require 'fluent/test/helpers'
33
+
34
+ include Fluent::Test::Helpers
@@ -1,41 +1,41 @@
1
- require_relative '../helper'
2
-
3
- class BookmarkSAXParserTest < Test::Unit::TestCase
4
-
5
- def setup
6
- @evtxml = WinevtBookmarkDocument.new
7
- @parser = Nokogiri::XML::SAX::Parser.new(@evtxml)
8
- end
9
-
10
- def test_parse
11
- bookmark_str = <<EOS
12
- <BookmarkList>
13
- <Bookmark Channel='Application' RecordId='161332' IsCurrent='true'/>
14
- </BookmarkList>
15
- EOS
16
- @parser.parse(bookmark_str)
17
- expected = {channel: "Application", record_id: 161332, is_current: true}
18
- assert_equal expected, @evtxml.result
19
- end
20
-
21
- def test_parse_2
22
- bookmark_str = <<EOS
23
- <BookmarkList>
24
- <Bookmark Channel='Security' RecordId='25464' IsCurrent='true'/>
25
- </BookmarkList>
26
- EOS
27
- @parser.parse(bookmark_str)
28
- expected = {channel: "Security", record_id: 25464, is_current: true}
29
- assert_equal expected, @evtxml.result
30
- end
31
-
32
- def test_parse_empty_bookmark_list
33
- bookmark_str = <<EOS
34
- <BookmarkList>
35
- </BookmarkList>
36
- EOS
37
- @parser.parse(bookmark_str)
38
- expected = {}
39
- assert_equal expected, @evtxml.result
40
- end
41
- end
1
+ require_relative '../helper'
2
+
3
+ class BookmarkSAXParserTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @evtxml = WinevtBookmarkDocument.new
7
+ @parser = Nokogiri::XML::SAX::Parser.new(@evtxml)
8
+ end
9
+
10
+ def test_parse
11
+ bookmark_str = <<EOS
12
+ <BookmarkList>
13
+ <Bookmark Channel='Application' RecordId='161332' IsCurrent='true'/>
14
+ </BookmarkList>
15
+ EOS
16
+ @parser.parse(bookmark_str)
17
+ expected = {channel: "Application", record_id: 161332, is_current: true}
18
+ assert_equal expected, @evtxml.result
19
+ end
20
+
21
+ def test_parse_2
22
+ bookmark_str = <<EOS
23
+ <BookmarkList>
24
+ <Bookmark Channel='Security' RecordId='25464' IsCurrent='true'/>
25
+ </BookmarkList>
26
+ EOS
27
+ @parser.parse(bookmark_str)
28
+ expected = {channel: "Security", record_id: 25464, is_current: true}
29
+ assert_equal expected, @evtxml.result
30
+ end
31
+
32
+ def test_parse_empty_bookmark_list
33
+ bookmark_str = <<EOS
34
+ <BookmarkList>
35
+ </BookmarkList>
36
+ EOS
37
+ @parser.parse(bookmark_str)
38
+ expected = {}
39
+ assert_equal expected, @evtxml.result
40
+ end
41
+ end