plogger 0.6.0 → 0.7.0

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: 0eccda185145e61a04ed1852fc0b0a491b982bb9
4
- data.tar.gz: 799b4e3385c2331a35485df4c9c540280f0c62bd
3
+ metadata.gz: a24e99ff9521bc048ab680b75e40167c7e16fbff
4
+ data.tar.gz: a6c6248a29d724b6c3eb3a72ea025c541c590e06
5
5
  SHA512:
6
- metadata.gz: fa49a8cb702a530d5348da9a58f94481e748ad6d7f1385dc94cfec4973b7a6db39ba36ea8d947a79c50d7ab3cee5ca10a684722212ed7a802e60352c4c9522c5
7
- data.tar.gz: 7d397906ac80b9679bb3d8bd2a4c39d5fc7f1defc564f8f204930df4bf377e49b89a493c41af55d151bbcea039725931585f0bdfeba2e7b8b8b3c41442a383c3
6
+ metadata.gz: 169c36b1bb0cab81074afbef97a44748b4e0d13ec1cc80a3c8b7d1e25c6bf332c3448da2b9988f554d4d3747c70ea42b5dbad104ec4e63751fc440c3b91e882b
7
+ data.tar.gz: 9b0f62923040fadb5cf4868b2e0d49d30bbbab20a10c846bf2c62ab074a7cef0b5c34229276cc4833d312fd0f941c1e520ebbccfafa3bab0ee4a2402ff761a7b
data/.gitignore CHANGED
@@ -1,10 +1,12 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
10
- plogger-*.gem
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ plogger-*.gem
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format documentation
2
2
  --color
3
+ --require spec_helper
data/.travis.yml CHANGED
@@ -2,4 +2,4 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.3.0
5
- before_install: gem install bundler -v 1.13.6
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in Plogger.gemspec
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in plogger.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -1,59 +1,39 @@
1
1
  # Plogger
2
2
 
3
- ## Introduction
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/plogger`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
- Plogger stands for Papinotas Logger or Phoenix Logger (our current project, which raised the need for this gem). Plogger is a simple logging gem which receives a little more information than `Rails.Logger`, and can also send an exception to third party APIs (currently only Raven is supported). Plogger outputs the log in a parser friendly format, ready for other software such as Logstash to process it.
5
+ TODO: Delete this and the text above, and describe your gem
6
6
 
7
- ## Instalation
7
+ ## Installation
8
8
 
9
- Add `gem 'plogger'` to your gemfile.
10
-
11
- ## Configuring
9
+ Add this line to your application's Gemfile:
12
10
 
13
11
  ```ruby
14
- # environments/[Environment].rb
15
- Rails.application.configure do
16
- Plogger.configure do |config|
17
- config.logger = ActiveSupport::Logger.new(STDOUT) # Or whatever logger you want to configure
18
- config.module = 'MainModule' # Optional
19
- config.raven_dsn = 'http://public:secret@example.com/project-id' # Optional
20
- end
21
- end
12
+ gem 'plogger'
22
13
  ```
23
14
 
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install plogger
22
+
24
23
  ## Usage
25
24
 
26
- The usage is similar to how you use the Rails Logger, but you can also log exceptions.
25
+ TODO: Write usage instructions here
27
26
 
28
- ```ruby
29
- begin
30
- 1/0
31
- rescue e
32
- trace = Plogger.exception(e, category: 'Bundle Creation')
33
- # => trace = "130AH93MWS2"
34
- return render "Too bad, an exception was raised. Read the full error at #{trace}"
35
- end
36
- trace_2 = Plogger.info("Processing ready", category: 'Bundle Creation')
37
- render "Your process finished successfully, check the logs at #{trace_2}"
38
- ```
27
+ ## Development
39
28
 
40
- Plogger has the following methods: `exception`, `error`, `warning`, `info`, `debug`. It will use the logger you supplied in the config to output them, so make sure you have enabled the log level you are trying to use.
29
+ 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.
41
30
 
42
- ## Params
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
32
 
44
- Each of these methods can receive the following keyword params:
33
+ ## Contributing
45
34
 
46
- | Param | Explanation | Default |
47
- | ------------- |---------------|-----------|
48
- | category | Use it to categorize the thing you are logging, so you can later group related logs in Kibana or something |''|
49
- | type | Use it to manifest if the current log is generated by a system action or a user action | 'system' |
50
- | user_id | Use it to track the user that is generating the log | ''
51
- | account_id | In Phoenix we use accounts (a user can have many accounts). You can track that too | '' |
52
- | extra_info | A hash with additional tags you can print in the log | {} |
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/plogger.
53
36
 
54
- Example call:
37
+ ## License
55
38
 
56
- ```ruby
57
- Plogger.info("Processing ready", type: 'user', category: "Bundle Creation", user_id: 1, extra_info: {happy: "yes"})
58
- # Will output 'Processing ready -- trace=194fjx43gp type='user' category='Bundle Creation' user_id=1 happy='yes'
59
- ```
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/bin/console CHANGED
@@ -11,4 +11,4 @@ require "plogger"
11
11
  # Pry.start
12
12
 
13
13
  require "irb"
14
- IRB.start
14
+ IRB.start(__FILE__)
@@ -0,0 +1,3 @@
1
+ module Plogger
2
+ VERSION = "0.7.0"
3
+ end
File without changes
@@ -1,13 +1,13 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'plogger/version'
4
+ require "plogger/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "plogger"
8
8
  spec.version = Plogger::VERSION
9
9
  spec.authors = ["Daniel Merrill"]
10
- spec.email = ["daniel@papinotas.com"]
10
+ spec.email = ["danielmerrill6@gmail.com"]
11
11
 
12
12
  spec.summary = "Phoenix Logging Interface."
13
13
  spec.description = "Provides a standard way to generate logs in the application."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Merrill
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: 2.7.1
69
69
  description: Provides a standard way to generate logs in the application.
70
70
  email:
71
- - daniel@papinotas.com
71
+ - danielmerrill6@gmail.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
@@ -78,17 +78,13 @@ files:
78
78
  - ".travis.yml"
79
79
  - Gemfile
80
80
  - LICENSE.txt
81
- - Plogger.gemspec
82
81
  - README.md
83
82
  - Rakefile
84
83
  - bin/console
85
84
  - bin/setup
86
- - lib/Plogger.rb
87
- - lib/Plogger/config.rb
88
- - lib/Plogger/formatter.rb
89
- - lib/Plogger/handler.rb
90
- - lib/Plogger/id_generator.rb
91
- - lib/Plogger/version.rb
85
+ - lib/plogger.rb
86
+ - lib/plogger/version.rb
87
+ - plogger.gemspec
92
88
  homepage: https://github.com/Papinotas-Desarrollo/Plogger
93
89
  licenses:
94
90
  - MIT
@@ -1,9 +0,0 @@
1
- module Plogger
2
- class Config
3
- attr_accessor :raven_dsn, :logger, :module
4
-
5
- def initialize(logger)
6
- @logger = logger
7
- end
8
- end
9
- end
@@ -1,24 +0,0 @@
1
- module Plogger
2
- class Formatter
3
- def self.format(message, trace, type: 'system', user_id: nil, account_id: nil, category: '', extra_info: {})
4
- result = "#{message} -- trace='#{trace}'"
5
- args = {type: type, category: category, user_id: user_id, account_id: account_id}
6
- args.each do |key, value|
7
- result = add_param_to_message(result, key, value) unless value.nil?
8
- end
9
-
10
- extra_info.keys.each do |key|
11
- result = add_param_to_message(result, key, extra_info[key])
12
- end
13
- result
14
- end
15
-
16
- def self.add_param_to_message(message, key, value)
17
- result = message
18
- is_string = value.class == String
19
- result += " #{key}=#{is_string ? "'" : ''}#{value}#{is_string ? "'" : ''}"
20
- result
21
- end
22
-
23
- end
24
- end
@@ -1,70 +0,0 @@
1
- require 'plogger/id_generator'
2
- require 'plogger/formatter'
3
-
4
- module Plogger
5
- class Handler
6
- def initialize(config)
7
- @logger = config.logger
8
- @module = config.module
9
- @raven_dsn = config.raven_dsn
10
- end
11
-
12
- def handle_exception(exception, type: '', category: '', user_id: nil, account_id: nil, extra_info: {})
13
- unless @raven_dsn == nil || @raven_dsn.blank?
14
- Raven.user_context(id: user_id)
15
- Raven.tags_context(account_id: account_id)
16
- Raven.capture_exception(exception)
17
- end
18
- handle_error(exception.message, category: category, user_id: user_id, account_id: account_id,
19
- extra_info: extra_info, type: type)
20
- end
21
-
22
- def handle_error(message, type: '', category: '', user_id: '', account_id: '', extra_info: {})
23
- result = generate_id_and_message(message, category: category, user_id: user_id,
24
- account_id: account_id, type: type,
25
- extra_info: generate_extra_info(extra_info))
26
- @logger.error(result[:message])
27
- result[:trace]
28
- end
29
-
30
- def handle_warning(message, type: '', category: '', user_id: '', account_id: '', extra_info: {})
31
- result = generate_id_and_message(message, category: category, user_id: user_id,
32
- account_id: account_id, type: type,
33
- extra_info: generate_extra_info(extra_info))
34
- @logger.warn(result[:message])
35
- result[:trace]
36
- end
37
-
38
- def handle_info(message, type: '', category: '', user_id: '', account_id: '', extra_info: {})
39
- result = generate_id_and_message(message, category: category, user_id: user_id,
40
- account_id: account_id, type: type,
41
- extra_info: generate_extra_info(extra_info))
42
- @logger.info(result[:message])
43
- result[:trace]
44
- end
45
-
46
- def handle_debug(message, type: '', category: '', user_id: '', account_id: '', extra_info: {})
47
- result = generate_id_and_message(message, category: category, user_id: user_id,
48
- account_id: account_id, type: type,
49
- extra_info: generate_extra_info(extra_info))
50
- @logger.debug(result[:message])
51
- result[:trace]
52
- end
53
-
54
- private
55
-
56
- def generate_id_and_message(message, type: '', category: '', user_id: '', account_id: '', extra_info: {})
57
- trace = Plogger::IdGenerator.generate
58
- formatted_message = Plogger::Formatter.format(message, trace, user_id: user_id,
59
- account_id: account_id,
60
- category: category,
61
- type: type,
62
- extra_info: extra_info)
63
- {trace: trace, message: formatted_message}
64
- end
65
-
66
- def generate_extra_info extra_info
67
- extra_info.merge({module: @module})
68
- end
69
- end
70
- end
@@ -1,11 +0,0 @@
1
- module Plogger
2
- class IdGenerator
3
- def self.generate
4
- [('a'..'z'), ('A'..'Z'), (0..9)].map(&:to_a).flatten.shuffle[0, id_length].join
5
- end
6
-
7
- def self.id_length
8
- 10
9
- end
10
- end
11
- end
@@ -1,3 +0,0 @@
1
- module Plogger
2
- VERSION = "0.6.0"
3
- end