tanga_services 0.0.8 → 0.0.9

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: 1549a8ff27e55f3795d8bae0e5726bfc697d825a
4
- data.tar.gz: f3844a6357b9887a5bd84bfc19f0a7764c24968b
3
+ metadata.gz: 822ad37d54bfe06ddc3a896c8bbf103d5cd37395
4
+ data.tar.gz: cff13f02251fdd626e2c2d723a34bf0fc526010b
5
5
  SHA512:
6
- metadata.gz: f862168a6ef9e9a2a776d2be7eefeeb54dcb5fc88238fa80d15ed30d4f35e7a8a0ab8890eb4e758836de3709be0ddcd14487a9dd70eb0bdad480d9f35f2afd58
7
- data.tar.gz: 83f2a2e675277defb14fa99e40f63718ab65b66ca5b4e21652bc1fbf89ccedb35420022dc4efcc23dbf40afc5a8ecca116cff284194f5a26de42cad25caca8eb
6
+ metadata.gz: b98f4c9db57dc52bcbddaea5a2ece7052e633ffdf35330df9e8e55517ddb9f9749a8c8e967c94406db8fff03416757421aa011787197244e0ced2b279d264998
7
+ data.tar.gz: 99dd1f2e6e61024c6c556089a41f63feffcd28550b203cf414cb558bf1ccc4231193329163fafe42af206132df0f430ced1abef90e7864056a8ba06217a9750d
@@ -10,11 +10,11 @@ module TangaServices
10
10
  # TangaServices.logger.error({message: "i crashed"})
11
11
  class Logger < Syslog::Logger
12
12
  def self.application_name=(application_name)
13
- @logger ||= Syslog::Logger.new(application_name, Syslog::LOG_LOCAL7)
13
+ @application_name = application_name
14
14
  end
15
15
 
16
16
  def self.logger
17
- @logger
17
+ @logger || Syslog::Logger.new((@application_name || 'unknown'), Syslog::LOG_LOCAL7)
18
18
  end
19
19
 
20
20
  def self.debug(hash)
@@ -45,14 +45,13 @@ module TangaServices
45
45
  end
46
46
 
47
47
  def self.log(level, hash)
48
- fail ArgumentError, 'must have application_name set' unless @logger
49
48
  unless hash.is_a?(Hash)
50
49
  hash = { object: hash }
51
50
  end
52
51
 
53
52
  fail ArgumentError, 'we just log hashes' unless hash.is_a?(Hash)
54
53
  data = { level: level, object: hash }
55
- @logger.send(level, data.to_json)
54
+ logger.send(level, data.to_json)
56
55
  end
57
56
 
58
57
  def self.method_missing(method, *args, &block)
@@ -1,3 +1,3 @@
1
1
  module TangaServices
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/spec/logger_spec.rb CHANGED
@@ -8,9 +8,10 @@ describe TangaServices do
8
8
 
9
9
  context '.application_name=' do
10
10
  it 'should open the log with application name' do
11
- logger = instance_double(Syslog::Logger)
11
+ logger = instance_double(Syslog::Logger, info: nil)
12
12
  expect(Syslog::Logger).to receive(:new).with('my_app', Syslog::LOG_LOCAL7).and_return(logger)
13
13
  TangaServices.logger.application_name = 'my_app'
14
+ TangaServices.logger.info(service: 'sup')
14
15
  end
15
16
  end
16
17
 
@@ -24,11 +25,6 @@ describe TangaServices do
24
25
  end
25
26
 
26
27
  context '.log' do
27
- it 'makes you set application name before' do
28
- expect{TangaServices.logger.info('not a hash')}.to \
29
- raise_error(ArgumentError, "must have application_name set")
30
- end
31
-
32
28
  it '#write is an info, can be a string' do
33
29
  logger = instance_double(Syslog::Logger)
34
30
  expect(Syslog::Logger).to receive(:new).with('my_app', Syslog::LOG_LOCAL7).and_return(logger)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tanga_services
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Van Dyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-25 00:00:00.000000000 Z
11
+ date: 2015-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape