slack-logger 0.4.1
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +50 -0
- data/Rakefile +34 -0
- data/lib/generators/slack_logger/install_generator.rb +12 -0
- data/lib/generators/templates/slack_logger.rb +38 -0
- data/lib/slack-logger.rb +22 -0
- data/lib/slack_logger/engine.rb +6 -0
- data/lib/slack_logger/logger.rb +13 -0
- data/lib/slack_logger/slack_io.rb +37 -0
- data/lib/slack_logger/version.rb +3 -0
- data/lib/tasks/slack_logger_tasks.rake +4 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8c955e77aba2b4fe3ac9f7cc757b1abf72f58893
|
4
|
+
data.tar.gz: 4efe7641a02fb280e55316695cb516af64510337
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 317b18b39e03a0dae340796b2a205b0e20fdce06fb892f3d3e839dc0807595c4e9ee55907a4abfb8465367e0d658631032382546aa961746362e44d4505cbded
|
7
|
+
data.tar.gz: ec355a698e89edee17fd120988eff0d5a5adac1fcbc8f3a6799cbdfc72597e884e37c0a8acea6166f92769db610cda0fb8a270b8e0e57eaad6b5b554219f6b46
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 josephverbeck
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# slack-logger
|
2
|
+
[](https://travis-ci.org/josephverbeck/slack-logger)
|
3
|
+
[](https://codeclimate.com/github/josephverbeck/slack-logger)
|
4
|
+
[](https://codeclimate.com/github/josephverbeck/slack-logger/coverage)
|
5
|
+
|
6
|
+
|
7
|
+
Simple Slack logger using ActiveSupport broadcast and slack-ruby-client
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'slack-logger'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
```bash
|
18
|
+
$ bundle install
|
19
|
+
```
|
20
|
+
|
21
|
+
Finally, run the install generator:
|
22
|
+
```bash
|
23
|
+
$ rails generate slack_logger:install
|
24
|
+
```
|
25
|
+
|
26
|
+
it will create the following initializer `config/initializers/slack_logger.rb`.
|
27
|
+
This file contains all the information about the existing configuration options.
|
28
|
+
|
29
|
+
##Configuration
|
30
|
+
The gem makes use of the rails log and slack-ruby-client to force logs to be sent to both your normal log
|
31
|
+
file and a slack channel.
|
32
|
+
|
33
|
+
To configure your rails application simple add the below code to where you setup your rails log
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
config.after_initialize do
|
37
|
+
config.logger.extend ActiveSupport::Logger.broadcast(SlackLogger.logger)
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
1. Fork it ( https://github.com/josephverbeck/slack-logger/fork )
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create a new Pull Request
|
48
|
+
|
49
|
+
## License
|
50
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Slack::Logger'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SlackLogger
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path("../../templates", __FILE__)
|
4
|
+
|
5
|
+
desc "Create a SlackLogger initializer"
|
6
|
+
|
7
|
+
def copy_initializer
|
8
|
+
template 'slack_logger.rb', 'config/initializers/slack_logger.rb'
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
SlackLogger.setup do |config|
|
2
|
+
|
3
|
+
## Logger
|
4
|
+
# ------
|
5
|
+
#
|
6
|
+
# The slack logger
|
7
|
+
#
|
8
|
+
## Default:
|
9
|
+
# config.logger ||= SlackLogger::Logger.new(SlackLogger::SlackIO)
|
10
|
+
|
11
|
+
## Log Level
|
12
|
+
# ---------
|
13
|
+
#
|
14
|
+
# The error level you would like to see in slack
|
15
|
+
# Note: We support all log levels, but you shouldn't do anything less then :ERROR as Slack only allows one message
|
16
|
+
# per minute.
|
17
|
+
#
|
18
|
+
## Default:
|
19
|
+
# config.logger.level = :ERROR
|
20
|
+
|
21
|
+
## Slack Client
|
22
|
+
# -------------
|
23
|
+
#
|
24
|
+
# The client in which you would like to use to communicate with slack
|
25
|
+
# Note: slack-ruby-client is imported with this gem and is recommended
|
26
|
+
#
|
27
|
+
## Default:
|
28
|
+
# config.client = Slack::Web::Client.new(:token => Rails.application.secrets.slack_api_token)
|
29
|
+
|
30
|
+
|
31
|
+
## Slack Channel
|
32
|
+
# -------------
|
33
|
+
#
|
34
|
+
# The channel for which you want the error message to appear on
|
35
|
+
#
|
36
|
+
## Default:
|
37
|
+
# config.channel = nil
|
38
|
+
end
|
data/lib/slack-logger.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'slack_logger/engine'
|
2
|
+
require 'slack-ruby-client'
|
3
|
+
|
4
|
+
module SlackLogger
|
5
|
+
|
6
|
+
mattr_accessor :channel
|
7
|
+
self.channel = nil
|
8
|
+
|
9
|
+
mattr_accessor :token
|
10
|
+
self.token = nil
|
11
|
+
|
12
|
+
mattr_accessor :client
|
13
|
+
self.token = nil
|
14
|
+
|
15
|
+
mattr_accessor :logger
|
16
|
+
self.logger = nil
|
17
|
+
|
18
|
+
def self.setup
|
19
|
+
yield self
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module SlackLogger
|
2
|
+
class SlackIO
|
3
|
+
|
4
|
+
def self.close
|
5
|
+
true
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.write(message)
|
9
|
+
unless message.blank?
|
10
|
+
client = SlackLogger.client
|
11
|
+
client.auth_test
|
12
|
+
client.chat_postMessage({
|
13
|
+
channel: SlackLogger.channel,
|
14
|
+
attachments: [{
|
15
|
+
pretext: message.to_s,
|
16
|
+
ts: "#{Time.now.utc.to_i}",
|
17
|
+
fields: [
|
18
|
+
{
|
19
|
+
title: "Project",
|
20
|
+
value: "#{Rails.application.class.parent_name}",
|
21
|
+
short: true
|
22
|
+
},
|
23
|
+
{
|
24
|
+
title: "Environment",
|
25
|
+
value: "#{Rails.env}",
|
26
|
+
short: true
|
27
|
+
}
|
28
|
+
],
|
29
|
+
color: "#F35A00"
|
30
|
+
}].to_json,
|
31
|
+
as_user: true})
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slack-logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- josephverbeck
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.0
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 5.0.0.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 5.0.0
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 5.0.0.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: slack-ruby-client
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.7.9
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.7.9
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: sqlite3
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rspec-rails
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
description: ''
|
104
|
+
email:
|
105
|
+
- joseph.verbeck@nih.gov
|
106
|
+
executables: []
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- MIT-LICENSE
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- lib/generators/slack_logger/install_generator.rb
|
114
|
+
- lib/generators/templates/slack_logger.rb
|
115
|
+
- lib/slack-logger.rb
|
116
|
+
- lib/slack_logger/engine.rb
|
117
|
+
- lib/slack_logger/logger.rb
|
118
|
+
- lib/slack_logger/slack_io.rb
|
119
|
+
- lib/slack_logger/version.rb
|
120
|
+
- lib/tasks/slack_logger_tasks.rake
|
121
|
+
homepage: https://github.com/josephverbeck/slack-logger
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.5.1
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Simple rails plugin that sends error messages to slack
|
145
|
+
test_files: []
|