hookworm-handlers 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +3 -0
  5. data/.simplecov +6 -0
  6. data/.travis.yml +17 -0
  7. data/.yardopts +1 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE.md +23 -0
  10. data/README.md +29 -0
  11. data/Rakefile +20 -0
  12. data/bin/hookworm-annotator +6 -0
  13. data/bin/hookworm-build-index-handler +6 -0
  14. data/bin/hookworm-logging-handler +6 -0
  15. data/bin/hookworm-rogue-commit-handler +6 -0
  16. data/hookworm-handlers.gemspec +32 -0
  17. data/lib/hookworm/annotator.rb +49 -0
  18. data/lib/hookworm/build_index_handler.rb +132 -0
  19. data/lib/hookworm/github_payload_annotator.rb +110 -0
  20. data/lib/hookworm/handlers/version.rb +5 -0
  21. data/lib/hookworm/handlers.rb +5 -0
  22. data/lib/hookworm/logging_handler.rb +55 -0
  23. data/lib/hookworm/rogue-commit-email-tmpl.erb +153 -0
  24. data/lib/hookworm/rogue_commit_handler.rb +240 -0
  25. data/lib/hookworm/travis_payload_annotator.rb +23 -0
  26. data/lib/hookworm-handlers.rb +7 -0
  27. data/sampledata/github-payloads/bogus.json +4 -0
  28. data/sampledata/github-payloads/branch_delete.json +41 -0
  29. data/sampledata/github-payloads/pull_request.json +153 -0
  30. data/sampledata/github-payloads/rogue.json +152 -0
  31. data/sampledata/github-payloads/rogue_unwatched_branch.json +152 -0
  32. data/sampledata/github-payloads/rogue_unwatched_path.json +91 -0
  33. data/sampledata/github-payloads/valid.json +66 -0
  34. data/sampledata/github-payloads/with_nulls.json +67 -0
  35. data/sampledata/travis-payloads/annotated_success.json +76 -0
  36. data/sampledata/travis-payloads/success.json +74 -0
  37. data/sampledata/travis-payloads/valid.json +56 -0
  38. data/spec/lib/hookworm/annotator_spec.rb +103 -0
  39. data/spec/lib/hookworm/build_index_handler_spec.rb +110 -0
  40. data/spec/lib/hookworm/logging_handler_spec.rb +134 -0
  41. data/spec/lib/hookworm/rogue_commit_handler_spec.rb +65 -0
  42. data/spec/spec_helper.rb +3 -0
  43. data/spec/support.rb +117 -0
  44. metadata +222 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGNjNDE5NjRiZmU2MjEwMTYyZTY1NjliZTA5NTRhNzFlZjY2NzZlNg==
5
+ data.tar.gz: !binary |-
6
+ NWY5NzA3NzUyN2FmOGE3OTY4NThmOWQzODRlYjQ0MTQzMWM2NWViMQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ M2Q2ODhkOWZmNTYxZDcyZWZlMzExZmUwZTJiNDcyODM3NDYzZDkwYTQxOTJi
10
+ MDNlMWYxNGVmZDQ2ODY0NjgzNzZiODM1NGY0Njk0NzI5OTE1ODQ0ZTQxNGM1
11
+ YTZiYmU3MGMyZmRiN2YwYWQ4ODU1ZmE3ZTBmMDgxNmJkN2JiZGE=
12
+ data.tar.gz: !binary |-
13
+ M2ZjNmE0MTAyNDg4MzY4MzYwMjUxZDFiN2U3NGY1NDJjNjEzYTYzYWM3NTY5
14
+ OWY1ZWU3NzE0MGE3MjQxOGJmZWU3N2Y0Yjg3MTA2YjliOTJhZTY1MWE0Nzg1
15
+ MjBiYzYyYTdmN2RjZDY3OGE0OGU3NTg3OTNmOGM1MmQ0NjM1MWY=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require pry
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ Documentation:
3
+ Enabled: false
data/.simplecov ADDED
@@ -0,0 +1,6 @@
1
+ if ENV['COVERAGE']
2
+ SimpleCov.start do
3
+ add_filter '/spec/'
4
+ end
5
+ end
6
+ # vim:filetype=ruby
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ ---
2
+ language: ruby
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1.0
6
+ notifications:
7
+ email: github+hookworm-handlers-ruby@modcloth.com
8
+ deploy:
9
+ provider: rubygems
10
+ api_key:
11
+ secure: C086LrlDlbLZpHSgKFWnCfsLqx4iaQRu/1CYCUgMCBkdGahaBNhR09C0JHosHQ7zshhoy+5EX4Oj7FDlqW/+tJbmMvkb5C6WkK87NqYM4UTB8NRvK5fzrQXh8a5pCE4ynoUrKMpN6nY43qeM5izHhk22Zkj35r+4OP4tYlf6lUw=
12
+ gem: hookworm-handlers
13
+ on:
14
+ tags: true
15
+ repo: modcloth-labs/hookworm-handlers-ruby
16
+ branch: master
17
+ rvm: 2.0.0
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hookworm-handlers.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,23 @@
1
+ Copyright © 2014 ModCloth, Inc.
2
+ ====================================
3
+
4
+ ## MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Hookworm Handlers
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'hookworm-handlers'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install hookworm-handlers
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rubocop/rake_task'
3
+ require 'rspec/core/rake_task'
4
+ require 'yard'
5
+
6
+ RSpec::Core::RakeTask.new(:test) do |t|
7
+ t.rspec_opts = '--format doc'
8
+ end
9
+
10
+ Rubocop::RakeTask.new(:rubocop)
11
+
12
+ YARD::Rake::YardocTask.new
13
+
14
+ desc 'Run rspec with coverage'
15
+ task :coverage do
16
+ ENV['COVERAGE'] = '1'
17
+ Rake::Task['test'].invoke
18
+ end
19
+
20
+ task default: [:rubocop, :coverage]
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # vim:fileencoding=utf-8
3
+ require 'hookworm-handlers'
4
+ require 'English'
5
+
6
+ exit Hookworm::Annotator.new.run!(ARGV) if $PROGRAM_NAME == __FILE__
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # vim:fileencoding=utf-8
3
+ require 'hookworm-handlers'
4
+ require 'English'
5
+
6
+ exit Hookworm::BuildIndexHandler.new.run!(ARGV) if $PROGRAM_NAME == __FILE__
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # vim:fileencoding=utf-8
3
+ require 'English'
4
+ require 'hookworm-handlers'
5
+
6
+ exit Hookworm::LoggingHandler.new.run!(ARGV) if $PROGRAM_NAME == __FILE__
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # vim:fileencoding=utf-8
3
+ require 'English'
4
+ require 'hookworm-handlers'
5
+
6
+ exit Hookworm::RogueCommitHandler.new.run!(ARGV) if $PROGRAM_NAME == __FILE__
@@ -0,0 +1,32 @@
1
+ # vim:fileencoding=utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hookworm/handlers/version'
5
+ require 'English'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'hookworm-handlers'
9
+ spec.version = Hookworm::Handlers::VERSION
10
+ spec.authors = ['Dan Buch']
11
+ spec.email = %w(d.buch@modcloth.com)
12
+ spec.description = %q{}
13
+ spec.summary = %q{}
14
+ spec.homepage = ''
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files`.split($RS)
18
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
20
+ spec.require_paths = %w(lib)
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'mail', '~> 2.5.4'
24
+ spec.add_development_dependency 'pry'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'rubocop'
28
+ spec.add_development_dependency 'simplecov'
29
+ spec.add_development_dependency 'yard'
30
+
31
+ spec.add_runtime_dependency 'hookworm-base', '~> 0.1'
32
+ end
@@ -0,0 +1,49 @@
1
+ # vim:fileencoding=utf-8
2
+
3
+ require 'json'
4
+ require 'hookworm-base'
5
+ require_relative 'github_payload_annotator'
6
+ require_relative 'travis_payload_annotator'
7
+
8
+ module Hookworm
9
+ # # Hookworm Annotator
10
+ #
11
+ # The annotator is responsible for adding fields to the incoming payloads so
12
+ # that subsequent handlers do not have to duplicate decision-making logic.
13
+ #
14
+ # ## GitHub payload annotation
15
+ # GitHub payloads are given the following additional fields dependending on
16
+ # the presence of certain options.
17
+ #
18
+ # ### `is_pr_merge`
19
+ # Is the payload the result of a pull request merge?
20
+ #
21
+ # ### `is_watched_branch`
22
+ # Is the payload for a branch that is "watched", depending on the presence of
23
+ # the `watched_branches` postfix keyword argument?
24
+ #
25
+ # ### `has_watched_path`
26
+ # Does the payload contain changes to a "watched" path, depending on the
27
+ # presence of the `watched_paths` postfix keyword argument?
28
+ class Annotator
29
+ include Hookworm::Base
30
+
31
+ private
32
+
33
+ def handle(type)
34
+ payload = JSON.parse(input_stream.read, symbolize_names: true)
35
+ output_stream.puts JSON.pretty_generate(
36
+ send(:"annotate_#{type}_payload", payload)
37
+ )
38
+ 0
39
+ end
40
+
41
+ def annotate_github_payload(github_payload)
42
+ Hookworm::GitHubPayloadAnnotator.new(cfg).annotate(github_payload)
43
+ end
44
+
45
+ def annotate_travis_payload(travis_payload)
46
+ Hookworm::TravisPayloadAnnotator.new.annotate(travis_payload)
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,132 @@
1
+ # vim:fileencoding=utf-8
2
+
3
+ require 'erb'
4
+ require 'fileutils'
5
+ require 'json'
6
+ require 'time'
7
+ require 'hookworm-base'
8
+ require 'hookworm/directory_index_updater'
9
+
10
+ module Hookworm
11
+ class BuildIndexHandler
12
+ include Hookworm::Base
13
+
14
+ private
15
+
16
+ def handle_travis
17
+ payload = JSON.parse(input_stream.read, symbolize_names: true)
18
+ TravisPayloadBuildIndexer.new(cfg, log).index(payload)
19
+ 0
20
+ rescue TravisPayloadBuildIndexer::InvalidPayload => e
21
+ log.error { e }
22
+ 1
23
+ ensure
24
+ output_stream.puts JSON.pretty_generate(payload)
25
+ 0
26
+ end
27
+ end
28
+
29
+ class TravisPayloadBuildIndexer
30
+ InvalidPayload = Class.new(StandardError)
31
+
32
+ attr_reader :cfg, :log
33
+
34
+ include FileUtils
35
+
36
+ def initialize(cfg, log)
37
+ @cfg = cfg
38
+ @log = log
39
+ end
40
+
41
+ def index(payload)
42
+ mkdir_p(index_prefix)
43
+ repo_slug = (payload[:repository] || {})[:slug]
44
+ unless repo_slug
45
+ fail InvalidPayload, "Invalid repo slug #{repo_slug.inspect}"
46
+ end
47
+ build_id_path = payload_build_id_path(repo_slug, payload)
48
+ mkdir_p(File.dirname(build_id_path))
49
+ write_payload(payload, build_id_path)
50
+ link_all_category_paths(payload, repo_slug, build_id_path)
51
+ update_all_directory_indexes(repo_slug)
52
+ end
53
+
54
+ private
55
+
56
+ def write_payload(payload, path)
57
+ File.open(path, 'w:UTF-8') do |f|
58
+ f.puts JSON.pretty_generate(payload)
59
+ end
60
+ end
61
+
62
+ def payload_build_id_path(repo_slug, payload)
63
+ "#{index_prefix}/#{repo_slug}/builds/#{payload[:id]}.json"
64
+ end
65
+
66
+ def link_all_category_paths(payload, repo_slug, build_id_path)
67
+ link_by_number_path(payload, repo_slug, build_id_path)
68
+ link_by_commit_paths(payload, repo_slug, build_id_path)
69
+ link_by_datetime_path(payload, repo_slug, build_id_path)
70
+ link_latest_build(repo_slug)
71
+ end
72
+
73
+ def link_by_number_path(payload, repo_slug, build_id_path)
74
+ mkdir_p_ln_sf(
75
+ build_id_path,
76
+ "#{index_prefix}/#{repo_slug}/builds/" <<
77
+ "_by_number/#{payload[:number]}.json"
78
+ )
79
+ end
80
+
81
+ def link_by_commit_paths(payload, repo_slug, build_id_path)
82
+ mkdir_p_ln_sf(
83
+ build_id_path,
84
+ "#{index_prefix}/#{repo_slug}/builds/" <<
85
+ "_by_commit/#{payload[:commit]}.json"
86
+ )
87
+ mkdir_p_ln_sf(
88
+ build_id_path,
89
+ "#{index_prefix}/#{repo_slug}/builds/_by_commit/" <<
90
+ "#{payload[:commit][0, 7]}.json"
91
+ )
92
+ end
93
+
94
+ def link_by_datetime_path(payload, repo_slug, build_id_path)
95
+ timestamp = Time.parse(payload[:finished_at]).strftime('%Y%m%d_%H%M%S')
96
+ mkdir_p_ln_sf(
97
+ build_id_path,
98
+ "#{index_prefix}/#{repo_slug}/builds/_by_datetime/#{timestamp}.json"
99
+ )
100
+ end
101
+
102
+ def link_latest_build(repo_slug)
103
+ builds_glob = "#{index_prefix}/#{repo_slug}/builds/_by_datetime/*.json"
104
+ latest = ''
105
+ Dir.glob(builds_glob) do |f|
106
+ latest = f if File.basename(f) > File.basename(latest)
107
+ end
108
+ mkdir_p_ln_sf(latest, "#{index_prefix}/#{repo_slug}/builds/_latest.json")
109
+ end
110
+
111
+ def update_all_directory_indexes(repo_slug)
112
+ indexer = Hookworm::DirectoryIndexUpdater.new(cfg)
113
+ %W(
114
+ #{index_prefix}
115
+ #{index_prefix}/#{File.dirname(repo_slug)}
116
+ ).each do |dir|
117
+ indexer.update_index!(dir)
118
+ end
119
+ indexer.update_all!("#{index_prefix}/#{repo_slug}")
120
+ end
121
+
122
+ def mkdir_p_ln_sf(src, dest)
123
+ mkdir_p(File.dirname(dest))
124
+ log.debug { "Linking #{src} -> #{dest}" }
125
+ ln_sf(src, dest)
126
+ end
127
+
128
+ def index_prefix
129
+ @index_prefix ||= "#{cfg[:static_dir]}/build-index"
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,110 @@
1
+ require 'logger'
2
+
3
+ module Hookworm
4
+ class GitHubPayloadAnnotator
5
+ attr_reader :cfg
6
+
7
+ PULL_REQUEST_MESSAGE_RE = /Merge pull request #[0-9]+ from.*/
8
+
9
+ def initialize(cfg)
10
+ @cfg = cfg
11
+ end
12
+
13
+ def annotate(payload)
14
+ payload.merge(
15
+ is_pr_merge: pr_merge?(payload),
16
+ is_watched_branch: watched_branch?(payload[:ref]),
17
+ has_watched_path: watched_path?(payload)
18
+ )
19
+ end
20
+
21
+ private
22
+
23
+ def pr_merge?(payload)
24
+ truth = (
25
+ (payload[:commits] || []).length > 1 &&
26
+ !!PULL_REQUEST_MESSAGE_RE.match(payload[:head_commit][:message])
27
+ )
28
+ log.debug { "pull request merge? #{truth}" }
29
+ truth
30
+ end
31
+
32
+ def watched_branch?(ref)
33
+ sans_refs_heads = ref.sub(%r{^refs/heads/}, '')
34
+ watched_branches.each do |br|
35
+ if sans_refs_heads =~ br
36
+ log.debug { "#{sans_refs_heads} =~ #{br.inspect} -> true" }
37
+ return true
38
+ end
39
+ log.debug { "#{sans_refs_heads} =~ #{br.inspect} -> false" }
40
+ end
41
+ false
42
+ end
43
+
44
+ def watched_branches
45
+ @watched_branches ||= watched_branch_strings.map { |wb| /#{wb}/ }
46
+ end
47
+
48
+ def watched_branch_strings
49
+ (
50
+ (cfg[:worm_flags] || {})[:watched_branches] || ''
51
+ ).cleanquotes.commasplit
52
+ end
53
+
54
+ def watched_path?(payload)
55
+ watched_paths.each do |wp|
56
+ payload_paths(payload).each do |path|
57
+ if path =~ wp
58
+ log.debug { "#{path} =~ #{wp.inspect} -> true" }
59
+ return true
60
+ end
61
+ log.debug { "#{path} =~ #{wp.inspect} -> false" }
62
+ end
63
+ end
64
+ false
65
+ end
66
+
67
+ def watched_paths
68
+ @watched_paths ||= watched_path_strings.map { |wp| /#{wp}/ }
69
+ end
70
+
71
+ def watched_path_strings
72
+ ((cfg[:worm_flags] || {})[:watched_paths] || '').cleanquotes.commasplit
73
+ end
74
+
75
+ def payload_paths(payload)
76
+ paths = []
77
+ commits = payload[:commits] || []
78
+ commits << payload[:head_commit]
79
+
80
+ commits.each_with_index do |commit, i|
81
+ next if payload[:is_pr_merge] && i == 0
82
+
83
+ paths += commit_paths(commit)
84
+ end
85
+
86
+ paths
87
+ end
88
+
89
+ def commit_paths(commit)
90
+ path_set = {}
91
+ return [] if commit.nil? || commit.empty?
92
+
93
+ [commit[:added], commit[:removed], commit[:modified]].each do |path_list|
94
+ path_list.each do |path|
95
+ path_set[path] = true
96
+ end
97
+ end
98
+
99
+ path_set.keys.sort
100
+ end
101
+
102
+ def log
103
+ @log ||= Logger.new(log_stream)
104
+ end
105
+
106
+ def log_stream
107
+ $stderr.set_encoding('UTF-8')
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,5 @@
1
+ module Hookworm
2
+ module Handlers
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Hookworm
2
+ module Handlers
3
+ autoload :VERSION, 'hookworm/handlers/version'
4
+ end
5
+ end
@@ -0,0 +1,55 @@
1
+ # vim:fileencoding=utf-8
2
+
3
+ require 'json'
4
+ require 'syslog'
5
+
6
+ require 'hookworm-base'
7
+
8
+ module Hookworm
9
+ # # Hookworm Logging Handler
10
+ #
11
+ # The logging handler is responsible for logging valid incoming requests,
12
+ # optionally logging to syslog if the `syslog=true` option is provided.
13
+ class LoggingHandler
14
+ include Hookworm::Base
15
+
16
+ private
17
+
18
+ def handle_github
19
+ payload = JSON.parse(input_stream.read, symbolize_names: true)
20
+ re_serialized_payload = JSON.pretty_generate(payload)
21
+
22
+ log_payload(payload, re_serialized_payload)
23
+ return 0
24
+ rescue => e
25
+ log.error { "#{e.class.name} #{e.message}" }
26
+ log.debug { e.backtrace.join("\n") }
27
+ return 1
28
+ end
29
+
30
+ def handle_travis
31
+ payload = JSON.parse(input_stream.read, symbolize_names: true)
32
+ re_serialized_payload = JSON.pretty_generate(payload)
33
+
34
+ log_payload(payload, re_serialized_payload)
35
+ return 0
36
+ rescue => e
37
+ log.error { "#{e.class.name} #{e.message}" }
38
+ log.debug { e.backtrace.join("\n") }
39
+ return 1
40
+ end
41
+
42
+ def log_payload(payload, re_serialized_payload)
43
+ log.debug { "payload=#{payload.inspect}" }
44
+ log.debug { "payload json=#{re_serialized_payload.inspect}" }
45
+
46
+ if (cfg[:worm_flags] || {})[:syslog]
47
+ Syslog.open($PROGRAM_NAME, Syslog::LOG_PID | Syslog::LOG_CONS) do |sl|
48
+ sl.info(re_serialized_payload)
49
+ end
50
+ end
51
+
52
+ output_stream.puts(re_serialized_payload)
53
+ end
54
+ end
55
+ end