logging-papertrail 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 74ddd77ef2d3ac04c82cb93db5e8d4c17d227579
4
+ data.tar.gz: d06829ee3203425ce4116b56f0c93403c9b1064b
5
+ SHA512:
6
+ metadata.gz: 3289fad9ccdf1cbcc2db7722bf71f808329e6c498c3746eac5d3cd06746385f3f586506b679317b6915c5439c04faf9b0a38b64a18f902fa762428cb581c763f
7
+ data.tar.gz: 5faa5bde533108f33800d9e4e3c00bc4841872de66dbf938a5f21fb7a6a74cc2e1f144e5120c20b5041cebf5a89c7aa32899de6cf8491ef2d128da0686c93712
@@ -0,0 +1,20 @@
1
+ Copyright 2018 AndyNasa
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.
@@ -0,0 +1,28 @@
1
+ # Logging::Papertrail
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'logging-papertrail'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install logging-papertrail
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,33 @@
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 = 'Logging::Papertrail'
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 << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+
33
+ task default: :test
@@ -0,0 +1,78 @@
1
+ require 'rollbar/rails'
2
+
3
+ module Logging
4
+ module Appenders
5
+ # Factory for the Papertrails appender.
6
+ def self.papertrail(*args)
7
+ str = '::Logging::Appenders::Rollbar needs a name as first argument.'
8
+ fail ArgumentError, str if args.empty?
9
+ ::Logging::Appenders::Papertrail.new(*args)
10
+ end
11
+
12
+ class Papertrail < ::Logging::Appender
13
+ def initialize(name, opts = {})
14
+ ::Logging.init unless ::Logging.initialized?
15
+
16
+ @name = name.to_s
17
+ @closed = false
18
+ @filters = []
19
+ @mutex = ReentrantMutex.new
20
+
21
+ self.layout = opts.fetch(:layout, ::Logging::Layouts::Basic.new)
22
+ self.level = opts.fetch(:level, nil)
23
+ self.encoding = opts.fetch(:encoding, self.encoding)
24
+ self.filters = opts.fetch(:filters, nil)
25
+
26
+ if opts.fetch(:header, true)
27
+ header = @layout.header
28
+
29
+ unless header.nil? || header.empty?
30
+ begin
31
+ write(header)
32
+ rescue StandardError => err
33
+ ::Logging.log_internal_error(err)
34
+ end
35
+ end
36
+ end
37
+
38
+ ::Logging::Appenders[@name] = self
39
+ end
40
+
41
+ def close(*args)
42
+ super(false)
43
+ end
44
+
45
+ private
46
+
47
+ def write(event)
48
+ is_log_event = event.instance_of?(::Logging::LogEvent)
49
+ message = is_log_event ? layout.format(event) : event.to_s
50
+ return if message.empty?
51
+
52
+ exception = event.data || StandardError.new(message)
53
+ severity =
54
+ case Logging::LNAMES[event.level]
55
+ when 'DEBUG', 'INFO'
56
+ 'info'
57
+ when 'WARN'
58
+ 'warning'
59
+ when 'ERROR', 'FATAL'
60
+ 'error'
61
+ end
62
+
63
+ message = JSON.parse(message).merge(severity: severity)
64
+ logger.error(exception)
65
+ end
66
+
67
+ def logger
68
+ @logger ||= ActiveSupport::TaggedLogging.new(
69
+ RemoteSyslogLogger.new(
70
+ 'logs2.papertrailapp.com', 35682,
71
+ program: 'rails-dev',
72
+ local_hostname: 'optional_hostname'
73
+ )
74
+ )
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,5 @@
1
+ module Logging
2
+ module Papertrail
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ module Logging
2
+ module Plugins
3
+ module Papertrail
4
+ module_function
5
+
6
+ # This method will be called by the Logging framework when it first
7
+ # initializes. Here we require the Papertrail [https://papertrailapp.com] appender code.
8
+ def initialize_papertrail
9
+ require File.expand_path('../../appenders/papertrail', __FILE__)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :logging_papertrail do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logging-papertrail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - AndyNasa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-15 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.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.1.4
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '5.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.1.4
33
+ - !ruby/object:Gem::Dependency
34
+ name: remote_syslog_logger
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: sqlite3
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description: The Papertrail [https://papertrailapp.com/] appender for the Ruby Logging
62
+ framework.
63
+ email:
64
+ - andriy.nasa@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - MIT-LICENSE
70
+ - README.md
71
+ - Rakefile
72
+ - lib/logging/appenders/papertrail.rb
73
+ - lib/logging/papertrail/version.rb
74
+ - lib/logging/plugins/papertrail.rb
75
+ - lib/tasks/logging/papertrail_tasks.rake
76
+ homepage: https://rubygems.org/gems/logging-paperclip
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.5.2.2
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Logging::Papertrail.
100
+ test_files: []