logdna-rails 1.0.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11213205c83286528992bb3ff2fa03af78f179a4
4
- data.tar.gz: 55e6835da1b56dcbd535e9b48a0ed9443608a7ba
3
+ metadata.gz: 0ba4c6225fa6411c486810667391805ee3a041a6
4
+ data.tar.gz: dcc2d050a26b5b9f77e78f31d82ffba719de7783
5
5
  SHA512:
6
- metadata.gz: 1b853af8bdf17a1af599673c111f213e23cda65a11863e5bb644561b971febb0bd7e717a489b054f8d6657d6891943940efff361aee79403bf45a468e2342a75
7
- data.tar.gz: 9773764115391c3b147834f141fa3609579a2eccc9fa0222bd102cc7fc787fb02e41c18850f3f8d9f1c7bfd08a4d9f8a1204b7fe12a71499cf18ee464aeb5056
6
+ metadata.gz: be43fd9a910e202a0b6c7567c717356df81aa1e88766f911b754a94bbd38e36c2f67e59ff681a08ab9ac8e01d63f93356ff853401b04b67ef9586c1de5d0c4a2
7
+ data.tar.gz: 9b40a4b55d885dc4c76acbd61ab66554b97d689c7d7f9ea7f1d73729c8daa5bf78533838e8a2700e4825e90933ad1e2329daba9044e1f5113beed8d9c597e7b4
@@ -0,0 +1 @@
1
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in logdna_ruby.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c)
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.
@@ -0,0 +1,130 @@
1
+
2
+ <p align="center">
3
+ <a href="https://app.logdna.com">
4
+ <img height="95" width="201" src="https://raw.githubusercontent.com/logdna/artwork/master/logo%2Bruby.png">
5
+ </a>
6
+ <p align="center">Rails gem for logging to <a href="https://app.logdna.com">LogDNA</a></p>
7
+ </p>
8
+
9
+ ---
10
+
11
+ * **[Installation](#installation)**
12
+ * **[Quick Setup](#quick-setup)**
13
+ * **[API](#api)**
14
+ * **[Contributing](#contributing)**
15
+ * **[License](#license)**
16
+
17
+ # Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'logdna-rails'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install logdna-rails
32
+
33
+
34
+
35
+ # Quick Setup
36
+
37
+ After installation, call
38
+
39
+ logger = Logdna::RailsLogger.new(your_api_key, options)
40
+ => #<Logdna::Ruby:0x00000000000000>
41
+
42
+ to set up the logger.
43
+
44
+ Options are optional variables that may contain hostname, app name, mac address, ip address, log level specified.
45
+
46
+ options = {
47
+ :hostname => myHostName,
48
+ :ip => myIpAddress,
49
+ :mac => myMacAddress,
50
+ :app => myAppName,
51
+ :level => "INFO", # LOG_LEVELS = ['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'] or your customized log level
52
+ :env => "PRODUCTION",
53
+ :meta => {:once => {:first => "nested1", :another => "nested2"}}
54
+ }
55
+
56
+ To send logs, use "log" method. Default log level is "INFO"
57
+
58
+ logger.log('This is my first log')
59
+ => "Saved" # Saved to buffer. Ready to be flushed automatically
60
+
61
+ Log a message with particular metadata, level, appname, environment (one-time)
62
+
63
+ logger.log('This is warn message', {:meta => {:meta => "data"}, :level => "WARN", :app => "awesome", :env => "DEVELOPMENT"})
64
+
65
+ Log a message with lasting metadata, level, appname, environment (lasting)
66
+
67
+ logger.meta = {:once => {:first => "nested1", :another => "nested2"}}
68
+ logger.level = 'FATAL' or logger.level = Logger::FATAL
69
+ logger.app = 'NEW APP NAME'
70
+ logger.env = 'PRODUCTION'
71
+ logger.log('This messages and messages afterwards all have the above values')
72
+
73
+ Clear current metadata, level, appname, environment
74
+
75
+ logger.clear
76
+
77
+ Check current log level:
78
+
79
+ logger.info? => true
80
+ logger.warn? => false
81
+
82
+ Log a message with a particular level easily
83
+
84
+ logger.warn('This is a warning message')
85
+ logger.fatal('This is a fatal message')
86
+
87
+
88
+ Hostname and app name cannot be more than 80 characters.
89
+
90
+
91
+ # Important Notes
92
+
93
+ 1. This logger assumes that you pass in json formatted data
94
+ 2. This logger is a singleton (do not create mutiple instances of the logger) even though the singleton structure is not strongly enforced.
95
+
96
+
97
+ # API
98
+
99
+ ## Logdna::RailsLogger.new(ingestion_key, options = {})
100
+
101
+ Instantiates a new instance of the class it is called on. ingestion_key is required.
102
+
103
+ | Options | Default |
104
+ |---------|---------|
105
+ |{ :hostname => Host name } | Device's default hostname |
106
+ |{ :mac => MAC address } | Nil |
107
+ |{ :ip => IP address } | Nil |
108
+ |{ :app => App name } | 'default' |
109
+ |{ :level => Log level } | 'INFO' |
110
+ |{ :env => STAGING, PRODUCTION .. etc} | Nil |
111
+ |{ :meta => metadata} | Nil |
112
+ |{ :flushtime => Log flush interval in seconds } | 0.25 seconds |
113
+ |{ :flushbyte => Log flush upper limit in bytes } | 500000 bytes ~= 0.5 megabytes |
114
+
115
+ Different log level displays log messages in different colors as well.
116
+ - ![TRACE DEBUG INFO Colors](https://placehold.it/15/515151/000000?text=+) "Trace" "Debug" "Info"
117
+ - ![WARN Color](https://placehold.it/15/ec9563/000000?text=+) "Warn"
118
+ - ![ERROR Fatal Colors](https://placehold.it/15/e37e7d/000000?text=+) "Error" "Fatal"
119
+
120
+
121
+
122
+ # Contributing
123
+
124
+ Bug reports and pull requests are welcome on GitHub at https://github.com/logdna/rails.
125
+
126
+
127
+
128
+ # License
129
+
130
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -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 @@
1
+ # Logfile created on 2017-08-09 10:32:49 -0700 by logger.rb/56815
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ require 'logdna'
4
+
5
+ module Logdna
6
+ class RailsLogger < Logdna::Ruby
7
+ include Logdna
8
+ attr_accessor :api_key, :opts
9
+
10
+ def initialize(api_key, opts={})
11
+ super(api_key, opts)
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,28 @@
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 = '1.0.1'
8
+ spec.authors = 'Gun Woo Choi'
9
+ spec.email = 'matt.choi@logdna.com'
10
+
11
+ spec.summary = 'LogDNA Rails Logger'
12
+ spec.homepage = 'https://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 'logdna', '~> 1.0.7'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.13'
25
+ spec.add_development_dependency 'rake', '~> 10.5'
26
+ spec.add_development_dependency 'rspec', '~> 3.5'
27
+ spec.add_development_dependency 'webmock', '~> 2.3'
28
+ end
data/test.rb ADDED
@@ -0,0 +1,40 @@
1
+ require 'require_all'
2
+ require_all 'lib'
3
+
4
+
5
+ options = {hostname: "yondfsoikplghjniodhnfvreulwignfewfnrleuwinf"}
6
+
7
+
8
+ logger1 = Logdna::RailsLogger.new('You API Key')
9
+
10
+ logger1.level = Logger::TRACE
11
+ logger1.log('is this trace')
12
+
13
+ =begin
14
+ logger1.level = Logger::WARN
15
+ logger1.log('This should be warn')
16
+ logger1.trace('This should be trace')
17
+ logger1.log('Again warn level')
18
+
19
+ logger1.log('Warn level log1')
20
+ logger1.info('Info level log1')
21
+ logger1.level = Logger::DEBUG
22
+ logger1.log('DEBUG log1')
23
+
24
+ logger1.app = 'NEW APP NAME'
25
+ logger1.env = 'Staging'
26
+ logger1.level = 'INFO'
27
+
28
+
29
+
30
+ logger1.level = 'INFO'
31
+ logger1.level == Logger::INFO
32
+
33
+
34
+ logger1.log('are changes all updated')
35
+ =end
36
+ sleep 3
37
+
38
+
39
+
40
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logdna-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gun Woo Choi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-10 00:00:00.000000000 Z
11
+ date: 2017-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logdna
@@ -85,7 +85,16 @@ email: matt.choi@logdna.com
85
85
  executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files: []
88
- files: []
88
+ files:
89
+ - ".gitignore"
90
+ - Gemfile
91
+ - LICENSE.txt
92
+ - README.md
93
+ - Rakefile
94
+ - deb5d62d893e82d6b03f3d4c20b96e15
95
+ - lib/logdna/rails.rb
96
+ - logdna-rails.gemspec
97
+ - test.rb
89
98
  homepage: https://github.com/logdna/rails
90
99
  licenses:
91
100
  - MIT