loggem 0.0.5 → 0.1.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: f25cd6561469046b0e72e6d5a66dae159c0cee10
4
- data.tar.gz: 86a3a00ff03ebc0c6a28ba7f70603ce3870570d2
3
+ metadata.gz: e79aa534ceca3ff20d6d870844aa3ab942341543
4
+ data.tar.gz: ec494bb7f9a1877562b5bf3d2a0ef8f08dd4f7ed
5
5
  SHA512:
6
- metadata.gz: bb1839fbc3027b904d95102849e57eb7cc1ea4047af35c6de673600ebfebf8e4dc5e3f22b3f8de4bd9bfbfacb226e194c071fff66a089d071bcf517e2915b15d
7
- data.tar.gz: c0965606410bd875daf00cb4ddbef687ae97725a1af5a6927cf23b2b9f20a1cab6b41f55b4ba9182768e15fc899364ed84d781cf4261336f89c5fce89f1912ce
6
+ metadata.gz: 1905e4ba60bf289f6f1e43b1de64c0a383ad0ce2ab98214060e5cae64f0e357984d241d3e232e1055b2c5cfff31d729511f26337269fc4f32a9e8375230802b2
7
+ data.tar.gz: 86639642466318d79846f6e03806a6b38e2d01a93f43f3438529f743e547a2ade01af474796bda0100dcf5469fb6b8a2e01ac1a89266ae64aa649435adecfdc0
data/.travis.yml CHANGED
@@ -1,7 +1,10 @@
1
1
  language: ruby
2
+ before_install:
3
+ - gem install bundler --version '>=1.11'
2
4
  rvm:
3
5
  - 1.9.3
4
6
  - 2.0.0
5
- - 2.1.5
6
- - 2.2.0
7
+ - 2.1.8
8
+ - 2.2.4
9
+ - 2.3.0
7
10
 
data/README.md CHANGED
@@ -1,24 +1,21 @@
1
- # Loggem [![Build Status](https://travis-ci.org/emartech/loggem.svg?branch=master)](https://travis-ci.org/emartech/loggem)
1
+ # Loggem [![Build Status](https://travis-ci.org/emartech/loggem.svg?branch=master)](https://travis-ci.org/emartech/loggem) [![Code Climate](https://codeclimate.com/github/emartech/loggem/badges/gpa.svg)](https://codeclimate.com/github/emartech/loggem) [![Gem Version](https://badge.fury.io/rb/loggem.svg)](http://badge.fury.io/rb/loggem)
2
2
 
3
- Simple log wrapper with different formatters. Minimal Rails/ActiveRecord/Sequel support, so far
3
+ Simple log wrapper with different formatters for Rails. Minimal ActiveRecord/Sequel support, so far.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Add it your application's Gemfile and run `bundle`:
8
8
 
9
9
  gem 'loggem'
10
10
 
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install loggem
18
-
19
11
  ## Usage
12
+ Add the following lines to the `config/application.rb`
20
13
 
21
- TODO: Write usage instructions here
14
+ config.loggem.enabled = true
15
+ # use your favorite logger (or skip it setting it to use STDOUT)
16
+ config.loggem.logger = ::Logging.logger.root
17
+ # replace activerecord's logsubscriber to the loggem's one
18
+ config.loggem.extensions = %w[active_record]
22
19
 
23
20
  ## Contributing
24
21
 
data/lib/loggem/logger.rb CHANGED
@@ -24,7 +24,11 @@ module Loggem
24
24
 
25
25
 
26
26
  [:debug, :info, :warn, :error, :fatal].each do |level|
27
- define_method level do |message, payload = {}|
27
+ define_method level do |message = nil, payload = {}, &block|
28
+ message ||= block.call if block
29
+
30
+ raise ArgumentError, 'Neither message nor block was given' if message.nil?
31
+
28
32
  log level, message, payload
29
33
  end
30
34
  end
@@ -1,3 +1,3 @@
1
1
  module Loggem
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -72,6 +72,22 @@ describe Loggem::Logger do
72
72
  end
73
73
 
74
74
 
75
+ it 'should log the result of the block given' do
76
+ allow(::Loggem::Event).to receive(:new).
77
+ with(level: :info, message: 'raw message', payload: {}, context: {}).
78
+ and_return(event)
79
+ expect(logger).to receive(:info).with('formatted message')
80
+
81
+ subject.formatter = formatter
82
+ subject.info { 'raw message' }
83
+ end
84
+
85
+
86
+ it 'should raise an error if neither message nor block was given' do
87
+ expect { subject.info }.to raise_error ArgumentError
88
+ end
89
+
90
+
75
91
  it 'should log a message with payload' do
76
92
  allow(::Loggem::Event).to receive(:new).
77
93
  with(level: :info, message: 'raw message', payload: 'payload', context: {}).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Istvan Demeter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.4.5
108
+ rubygems_version: 2.5.1
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Simple log wrapper with different formatters. Rails/ActiveRecord/Sequel support,