influxdb 0.1.2 → 0.1.3

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: 3cfda4b23fa6e69256f6309aa37b2b84b4b00fe9
4
- data.tar.gz: d9ca155910d5323850f3dc11f76a20f6d4520747
3
+ metadata.gz: 89e34f73dc79fdd7911d7b95222437c9a36b3839
4
+ data.tar.gz: 2e62a50a70a4b7848a66a84d1033d49194d09445
5
5
  SHA512:
6
- metadata.gz: 755051222fdd660fbc2b0b43bd6e3b07e153fe81193b9152f0b03e2eeedb6bccdcac0aeb67ec10b824efc0446597b9c2629fbb0117ca27739af12d35f1ff4466
7
- data.tar.gz: 764110f71894216a9032505fc2bdd8f0ad5580fce387a8b420a3d0eff01b16ab86b8525543c5d42793ebc090e090ac1281d42d70b7d264693a8ac4ed64fd2560
6
+ metadata.gz: 04a951e2106d61547d4409ebac4dcb2055c5d38012fc9b40cb97d46af7dfa9426fc27f7a27b7657e9587faf7d15d322d2e80a4b7f8da6967e2fc06edcff1458b
7
+ data.tar.gz: 51ec22a345e521fc8adcfd7ec71a2bc488098d389b9b9463a51acd2ea262c86297d4d015fd5ceb8fb026eba9a9ecf6f82ed985f3dce62ee8641da7668f298e48
@@ -15,7 +15,7 @@ module InfluxDB
15
15
 
16
16
  attr_accessor :queue, :worker
17
17
 
18
- include InfluxDB::Logger
18
+ include InfluxDB::Logging
19
19
 
20
20
  # Initializes a new InfluxDB client
21
21
  #
@@ -1,10 +1,20 @@
1
+ require 'logger'
2
+
1
3
  module InfluxDB
2
- module Logger
4
+ module Logging
3
5
  PREFIX = "[InfluxDB] "
4
6
 
7
+ def self.logger=(new_logger)
8
+ @logger = new_logger
9
+ end
10
+
11
+ def self.logger
12
+ @logger ||= ::Logger.new(STDERR).tap {|logger| logger.level = Logger::INFO}
13
+ end
14
+
5
15
  private
6
16
  def log(level, message)
7
- STDERR.puts(PREFIX + "(#{level}) #{message}") unless level == :debug
17
+ InfluxDB::Logging.logger.send(level.to_sym, PREFIX + message)
8
18
  end
9
19
  end
10
20
  end
@@ -1,3 +1,3 @@
1
1
  module InfluxDB
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -7,7 +7,7 @@ module InfluxDB
7
7
  attr_reader :client
8
8
  attr_accessor :queue
9
9
 
10
- include InfluxDB::Logger
10
+ include InfluxDB::Logging
11
11
 
12
12
  MAX_POST_POINTS = 1000
13
13
  NUM_WORKER_THREADS = 3
@@ -1,29 +1,36 @@
1
1
  require 'spec_helper'
2
+ require 'logger'
2
3
 
3
- describe InfluxDB::Logger do
4
+ describe InfluxDB::Logging do
4
5
  class LoggerTest
5
- include InfluxDB::Logger
6
+ include InfluxDB::Logging
6
7
 
7
8
  def write_to_log(level, message)
8
9
  log(level, message)
9
10
  end
11
+
10
12
  end
11
13
 
12
- subject { LoggerTest.new }
14
+ before { @old_logger = InfluxDB::Logging.logger }
15
+ after { InfluxDB::Logging.logger = @old_logger }
13
16
 
14
- context 'with DEBUG level' do
15
- it 'should not write a log message to STDERR' do
16
- expect(STDERR).to_not receive(:puts)
17
+ it "has a default logger" do
18
+ expect(InfluxDB::Logging.logger).to be_a(Logger)
19
+ end
17
20
 
18
- subject.write_to_log(:debug, 'debug')
19
- end
21
+ it "allows setting of a logger" do
22
+ new_logger = Logger.new(STDOUT)
23
+ InfluxDB::Logging.logger = new_logger
24
+ expect(InfluxDB::Logging.logger).to eq(new_logger)
20
25
  end
21
26
 
22
- context 'with non-DEBUG level' do
23
- it 'should write a log message to STDERR' do
24
- expect(STDERR).to receive(:puts).with('[InfluxDB] (info) info')
27
+ context "when included in classes" do
28
+
29
+ subject { LoggerTest.new }
25
30
 
26
- subject.write_to_log(:info, 'info')
31
+ it "logs" do
32
+ expect(InfluxDB::Logging.logger).to receive(:debug).with(an_instance_of(String)).once
33
+ subject.write_to_log(:debug, 'test')
27
34
  end
28
35
  end
29
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Persen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-08 00:00:00.000000000 Z
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json