log4r_hipchat_outputter 0.9.9
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/Gemfile +14 -0
- data/README.md +18 -0
- data/Rakefile +42 -0
- data/init.rb +1 -0
- data/lib/log4r/outputter/hipchat_outputter.rb +52 -0
- data/lib/log4r_hipchat_outputter.rb +1 -0
- data/lib/log4r_hipchat_outputter/version.rb +4 -0
- data/log4r_hipchat_outputter.gemspec +20 -0
- metadata +85 -0
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in partitioned.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use debugger
|
14
|
+
# gem 'ruby-debug'
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
log4r outputter support for hipchat
|
2
|
+
|
3
|
+
```yaml
|
4
|
+
outputters:
|
5
|
+
- type : HipchatOutputter
|
6
|
+
name : hipchatter
|
7
|
+
level : ALARM
|
8
|
+
api_token: 'xxxxxxxxx'
|
9
|
+
room : 'my room'
|
10
|
+
color : 'red'
|
11
|
+
username : 'the program'
|
12
|
+
notify : 'true'
|
13
|
+
message_format: 'text'
|
14
|
+
formatter:
|
15
|
+
date_pattern: '%y%m%d %H:%M:%S.%L'
|
16
|
+
pattern : '%d %p %C %l %M'
|
17
|
+
type : PatternFormatter
|
18
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'rdoc/task'
|
10
|
+
rescue LoadError
|
11
|
+
require 'rdoc/rdoc'
|
12
|
+
require 'rake/rdoctask'
|
13
|
+
RDoc::Task = Rake::RDocTask
|
14
|
+
end
|
15
|
+
|
16
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = 'Log4r Hipchat Outputter'
|
19
|
+
rdoc.options << '--line-numbers'
|
20
|
+
rdoc.rdoc_files.include('README')
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
end
|
23
|
+
|
24
|
+
# Eventually we will want a test application to use this Engine
|
25
|
+
# to see if it works!
|
26
|
+
|
27
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
28
|
+
|
29
|
+
load 'rails/tasks/engine.rake'
|
30
|
+
|
31
|
+
Bundler::GemHelper.install_tasks
|
32
|
+
|
33
|
+
require 'rake'
|
34
|
+
require 'rspec/core'
|
35
|
+
require 'rspec/core/rake_task'
|
36
|
+
|
37
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
38
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'Default: Run all specs.'
|
42
|
+
task :default => :spec
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'log4r_hipchat_outputter.rb'
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'log4r/outputter/outputter'
|
2
|
+
require 'log4r/staticlogger'
|
3
|
+
require 'hipchat'
|
4
|
+
|
5
|
+
module Log4r
|
6
|
+
class HipchatOutputter < Outputter
|
7
|
+
attr_reader :api_token, :room, :color, :username, :notify, :message_format
|
8
|
+
|
9
|
+
def initialize(_name, hash={})
|
10
|
+
super(_name, hash)
|
11
|
+
validate(hash)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def validate(hash)
|
17
|
+
@api_token = (hash[:api_token] or hash['api_token'])
|
18
|
+
@room = (hash[:room] or hash['room'] or "alarms")
|
19
|
+
@username = (hash[:username] or hash['username'] or "Log4r")
|
20
|
+
@color = (hash[:color] or hash['color'] or "yellow") # red, purple, green, gray, random
|
21
|
+
@notify = (hash[:notify] or hash['notify']) == "true"
|
22
|
+
@message_format = (hash[:message_format] or hash['message_format'] or "text") # or "html"
|
23
|
+
|
24
|
+
@hipchat_options = {
|
25
|
+
:color => @color,
|
26
|
+
:notify => @notify,
|
27
|
+
:message_format => @message_format
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def canonical_log(event)
|
32
|
+
synch {
|
33
|
+
send_hipchat @formatter.format event
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def send_hipchat(msg)
|
38
|
+
### send email
|
39
|
+
begin
|
40
|
+
@client ||= HipChat::Client.new(@api_token)
|
41
|
+
@client[@room].send(@username, msg, @hipchat_options)
|
42
|
+
rescue Exception => e
|
43
|
+
Logger.log_internal(-2) {
|
44
|
+
"HipchatOutputter '#{@name}' couldn't send hipchat!"
|
45
|
+
}
|
46
|
+
Logger.log_internal {e}
|
47
|
+
self.level = OFF
|
48
|
+
raise e
|
49
|
+
end # begin
|
50
|
+
end # def send_mail
|
51
|
+
end # class HipchatOutputter
|
52
|
+
end # module Log4r
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'log4r/outputter/hipchat_outputter.rb'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "log4r_hipchat_outputter/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'log4r_hipchat_outputter'
|
8
|
+
s.version = Log4rHipchatOutputter::VERSION
|
9
|
+
s.license = 'New BSD License'
|
10
|
+
s.date = '2013-08-01'
|
11
|
+
s.summary = "Log4r outputter for hipchat."
|
12
|
+
s.description = "an log4r outputter for hipchat."
|
13
|
+
s.authors = ["Keith Gabryelski"]
|
14
|
+
s.email = 'keith@fiksu.com'
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.homepage = 'http://github.com/keithgabryelski/log4r_hipchat_outputter'
|
18
|
+
s.add_dependency "log4r"
|
19
|
+
s.add_dependency "hipchat"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: log4r_hipchat_outputter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.9
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Keith Gabryelski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: log4r
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: hipchat
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: an log4r outputter for hipchat.
|
47
|
+
email: keith@fiksu.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- Gemfile
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- init.rb
|
56
|
+
- lib/log4r/outputter/hipchat_outputter.rb
|
57
|
+
- lib/log4r_hipchat_outputter.rb
|
58
|
+
- lib/log4r_hipchat_outputter/version.rb
|
59
|
+
- log4r_hipchat_outputter.gemspec
|
60
|
+
homepage: http://github.com/keithgabryelski/log4r_hipchat_outputter
|
61
|
+
licenses:
|
62
|
+
- New BSD License
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.24
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Log4r outputter for hipchat.
|
85
|
+
test_files: []
|