flnt 0.2.0 → 0.3.0

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: b571a4742a35bac7d8b9b94fdd9f764ba19d3f95
4
- data.tar.gz: 6795af010a0846ef8250a3a27fb64b292cc4baab
3
+ metadata.gz: e5db5e21e64f6f18c0548f773dcc2c3281dbcf5d
4
+ data.tar.gz: 8b502467a7ca86abf718ddc0ee1cb56188c878f7
5
5
  SHA512:
6
- metadata.gz: 04d5b1811f70c88b598ad5690565dff3a259dd741543c885848f7cc91f2f93467bedce0282003ac55a21cb6e0ba73d3f313f434ddd929fef24184f61d49efc0d
7
- data.tar.gz: f1f7dedc3d305b4a255a72fa53479a2ad70c3d848369b70f79b8a5c3c678757ed5c9573f2188d3bd53b9ecff5e82906a79253343d1b7c47dd2cd4b96f84ef03a
6
+ metadata.gz: 5958b7cd81854817d8d46439a86c766f06a09b80a004a29e8c0e40f7d0c49b1925a1d3f3146e110933197f4a8f8e6dbc5b67a944fbe233a14254052dc6206ec7
7
+ data.tar.gz: 8fbc128b84488563d8ae990e17250ad8116ac256e1449086e68c7bae570dc3febb3ce019ecc70a67a8963754a1842fd59a55dca5c80f09893651a98d6f88ce5d
data/lib/flnt/logger.rb CHANGED
@@ -11,9 +11,10 @@ module Flnt
11
11
  def method_missing(name, *args)
12
12
  return super if name.to_s =~ /(!|\?)$/
13
13
 
14
- @tag = [@tag, name.to_s].join('.')
15
- unless args.empty?
16
- emit! args.first
14
+ if !args.empty?
15
+ emit! args.first, tag: [@tag, name.to_s].join('.')
16
+ else
17
+ @tag << "." << name.to_s
17
18
  end
18
19
 
19
20
  return self
@@ -22,17 +23,18 @@ module Flnt
22
23
  # method caching for common log level name
23
24
  %w(debug info warn error fatal).each do |log_level|
24
25
  define_method log_level do |*args|
25
- @tag << "." << log_level.to_s
26
- unless args.empty?
27
- emit! args.first
26
+ if !args.empty?
27
+ emit! args.first, tag: [@tag, log_level].join('.')
28
+ else
29
+ @tag << "." << log_level
28
30
  end
29
31
 
30
32
  return self
31
33
  end
32
34
  end
33
35
 
34
- def emit!(arg)
35
- ::Fluent::Logger.post @tag, to_info!(arg)
36
+ def emit!(arg, tag: nil)
37
+ ::Fluent::Logger.post((tag || @tag), to_info!(arg))
36
38
  end
37
39
 
38
40
  def tee!(logger_or_path)
@@ -5,16 +5,16 @@ module Flnt
5
5
  class TeeableLogger < Flnt::Logger
6
6
  attr_accessor :teed_logger
7
7
 
8
- def emit!(arg)
9
- level = __get_last_tag!
8
+ def emit!(arg, tag: nil)
9
+ level = __get_last_tag!(tag || @tag)
10
10
  level = 'info' unless %w(debug info warn error fatal).include?(level)
11
11
  teed_logger.send(level, arg)
12
12
  super
13
13
  end
14
14
 
15
15
  private
16
- def __get_last_tag!
17
- @tag.split('.').last
16
+ def __get_last_tag!(tag)
17
+ tag.split('.').last
18
18
  end
19
19
  end
20
20
  end
data/lib/flnt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Flnt
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -26,6 +26,16 @@ describe "Flnt::Logger" do
26
26
  }.to raise_error NoMethodError
27
27
  end
28
28
 
29
+ it "should not cache tag called with args" do
30
+ logger = Flnt.sample.foo
31
+ expect(Fluent::Logger).not_to receive(:post).with("sample.foo.info.info", {message: "Hello multi times"})
32
+ expect(Fluent::Logger).to receive(:post).with("sample.foo.info", {message: "Hello multi times"}).thrice
33
+
34
+ 3.times do
35
+ logger.info "Hello multi times"
36
+ end
37
+ end
38
+
29
39
  describe "should send messages when called with arg" do
30
40
  context "when String" do
31
41
  specify do
data/wercker.yml CHANGED
@@ -2,22 +2,15 @@ box: wercker/rvm
2
2
  build:
3
3
  steps:
4
4
  - rvm-use:
5
- version: ruby-2.1.0
5
+ version: ruby-2.1.5
6
6
  - bundle-install
7
7
  - script:
8
8
  name: run rspec
9
9
  code: bundle exec rake spec
10
10
 
11
11
  - rvm-use:
12
- version: ruby-2.0.0-p353
12
+ version: ruby-2.0.0-p598
13
13
  - bundle-install
14
14
  - script:
15
15
  name: run rspec
16
16
  code: bundle exec rake spec
17
-
18
- - rvm-use:
19
- version: ruby-1.9.3-p545
20
- - bundle-install
21
- - script:
22
- name: run rspec
23
- code: bundle exec rake spec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flnt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio KONDO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluent-logger