logdna-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da04adfa6e0cff4618bb5684cc6a3b18d469d857
4
- data.tar.gz: dc22c1f34e1c6073b53fcad298cb607e93120957
3
+ metadata.gz: aeb07c40058b90bc566f20dc7d6eb1944e52d566
4
+ data.tar.gz: f4752c49655056d4c5b16de1b538a5c11f8a77d4
5
5
  SHA512:
6
- metadata.gz: e0e26fcfb802a60e06fad3f7ec1a27d8f73f281b31b26fe8a0f53f3e4cfebbe467dd4d1c5899a6009396dd90beb201679851ddf88b4a75fe42215ad9fa6bf8ee
7
- data.tar.gz: 5f0828054d9d6351f85380c37b14b6e61d4d5d97d8d55d74282ad4c330fd87de77ef2454228ee8f1fb636c70ec859a96cb309c26e330193152b544f2ee8791b5
6
+ metadata.gz: 779768d3a5af39dd7165c328f2d6ac766a506c469911689f4786d53f46d340b87c4c9c463577ecf48a1f131c4940c61ec578611af6727fdeada1c31ac51ff5f8
7
+ data.tar.gz: a65ddbf17b4d230dd84407440993f09d18197fac9d7cb33ce335778b6003919eae99570bc9131059470a358f8ba179849fa4a1636eeba9f485fcfe7c99da82a0
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
11
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in logdna-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 edwin-lai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,113 @@
1
+ <p align="center">
2
+ <a href="https://app.logdna.com">
3
+ <img height="95" width="201" src="https://raw.githubusercontent.com/logdna/artwork/master/logo%2Bruby.png">
4
+ </a>
5
+ <p align="center">Rails logger plugin for logging to <a href="https://app.logdna.com">LogDNA</a></p>
6
+ </p>
7
+
8
+ ---
9
+
10
+ * **[Overview](#overview)**
11
+ * **[Installation](#installation)**
12
+ * **[API](#api)**
13
+ * **[Development](#development)**
14
+ * **[Contributing](#contributing)**
15
+ * **[License](#license)**
16
+
17
+ # Overview
18
+
19
+ This gem contains LogDNA::RailsLogger, a plugin for ActiveSupport::Logger from Rails.
20
+
21
+ # Installation
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ ```ruby
26
+ gem 'logdna-rails'
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ $ bundle
32
+
33
+ Or install it yourself as:
34
+
35
+ $ gem install logdna-rails
36
+
37
+ # Quick Setup
38
+
39
+ After installation, call
40
+
41
+ logger = LogDNA::RailsLogger.new(your_api_key, hostname)
42
+
43
+ to set up the logger.
44
+
45
+ To send logs, use exactly like the logger from the Ruby standard library. For example:
46
+
47
+ require 'logdna'
48
+
49
+ logger = LogDNA::RailsLogger.new(your_api_key, hostname)
50
+
51
+ logger.debug("Created logger")
52
+ logger.info("Program started")
53
+ logger.warn("Nothing to do!")
54
+
55
+ path = "a_non_existent_file"
56
+
57
+ begin
58
+ File.foreach(path) do |line|
59
+ unless line =~ /^(\w+) = (.*)$/
60
+ logger.error("Line in wrong format: #{line.chomp}")
61
+ end
62
+ end
63
+ rescue => err
64
+ logger.fatal("Caught exception; exiting")
65
+ logger.fatal(err)
66
+ end
67
+
68
+ # API
69
+
70
+ ## ::new(api_key, hostname, options = {})
71
+
72
+ Instantiates a new instance of the class it is called on. api_key and hostname are required.
73
+
74
+ Options:
75
+ * logdev: The log device. This is a filename (String) or IO object (e.g. STDOUT, STDERR, an open file). Default: STDOUT.
76
+ * mac: MAC address. Default: nil.
77
+ * ip: IP address. Default: nil.
78
+ * default_app: Set a default app for this instance of the logger. Note that this can be overwritten by the progname below on the line level, as the app is a line attribute.
79
+ * environment: Alias for default_app.
80
+
81
+ __Make sure that the following options are numbers if you supply them. We are not responsible for any type errors if you enter non-numerical values for these options.__
82
+
83
+ * shift_age: Number of old log files to keep, or frequency of rotation (daily, weekly, or monthly). Default: 7
84
+ * shift_size: Maximum logfile size (only applies when shift_age is a number). Default: 1,048,576
85
+ * buffer_max_size: Maximum number of lines in buffer. Default: 10
86
+ * buffer_timeout: Frequency of posting requests to LogDNA. Default: 10 (seconds)
87
+
88
+ ## \#add(severity, message=nil, progname=nil) {...}
89
+
90
+ Log a message if the given severity is high enough and post it to the LogDNA ingester. This is the generic logging method. Users will be more inclined to use debug, info, warn, error, and fatal (which all call \#add), as [described in the Ruby Logger documentation](https://ruby-doc.org/stdlib-2.3.0/libdoc/logger/rdoc/Logger.html). Note that these methods take a source as the argument and a block which returns a message. It returns the http response.
91
+
92
+ Note that the Rails logger documentation is located [here](http://api.rubyonrails.org/classes/ActiveSupport/Logger.html), but it's not very helpful.
93
+
94
+ ## \#close_http
95
+
96
+ Close the HTTP connection to LogDNA's ingester.
97
+
98
+ ## \#reopen_http
99
+
100
+ Open another HTTP connection to LogDNA's ingester if the connection is already closed.
101
+
102
+ # Development
103
+
104
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
105
+
106
+ # Contributing
107
+
108
+ Bug reports and pull requests are welcome on GitHub at https://github.com/logdna/ruby.
109
+
110
+ # License
111
+
112
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
113
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,19 @@
1
+ require 'http'
2
+ require 'active_support/logger'
3
+ require 'logdna'
4
+
5
+ module LogDNA
6
+ class RailsLogger < ActiveSupport::Logger
7
+ include LogDNA
8
+
9
+ attr_reader :open
10
+ attr_accessor :api_key, :host, :default_app, :ip, :mac
11
+
12
+ def initialize(api_key, hostname, options = {})
13
+ @conn = HTTP.persistent LogDNA::INGESTER_DOMAIN
14
+ opts = fill_opts_with_defaults(options)
15
+ super(opts[:logdev], opts[:shift_age], opts[:shift_size])
16
+ set_ivars(api_key, hostname, options)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'logdna-rails'
7
+ spec.version = '0.0.5'
8
+ spec.author = 'Edwin Lai'
9
+ spec.email = 'edwin@logdna.com'
10
+
11
+ spec.summary = 'ActiveSupport::Logger plugin for LogDNA'
12
+ spec.homepage = 'http://github.com/logdna/rails'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_runtime_dependency 'http', '~> 2.0'
23
+ spec.add_runtime_dependency 'activesupport', '>= 4.0', '< 6.0'
24
+ spec.add_runtime_dependency 'logdna', '~> 0.0.8'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.13'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'webmock', '~> 2.1'
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logdna-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edwin Lai
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 0.0.7
53
+ version: 0.0.8
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 0.0.7
60
+ version: 0.0.8
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: bundler
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -120,8 +120,16 @@ executables: []
120
120
  extensions: []
121
121
  extra_rdoc_files: []
122
122
  files:
123
+ - ".gitignore"
124
+ - ".rspec"
125
+ - Gemfile
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
123
129
  - bin/console
124
130
  - bin/setup
131
+ - lib/logdna/rails.rb
132
+ - logdna-rails.gemspec
125
133
  homepage: http://github.com/logdna/rails
126
134
  licenses:
127
135
  - MIT