logspot 0.3.0 → 0.4.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: 3cf2c3ec6355f5719971cf3e8785ef9095762987
4
- data.tar.gz: 62d40f3406ee336f338af18663ee4de42993c30b
3
+ metadata.gz: 6595774b426267654aafd83076d8e173ca7b320d
4
+ data.tar.gz: 25d9c409f6bf3db7a88860332a77620f8994c501
5
5
  SHA512:
6
- metadata.gz: b6cb704f0113685b434ddaa256904de184831d240d00f4483e1e57562d198bca7420ff114ab34c450d5bae524c4362d6e99fad0a965c07f76fb6f3b2f63e1adf
7
- data.tar.gz: 02d5bcb374621a0815dc0cdc0150ece1cca41d4b5ac493a4d723dc2e40a6eadef5634d93c65ca1b832cbaf9756e443eb1aab4f222cecf134b2ab10dfd67b117a
6
+ metadata.gz: 5d9fd46216eda1d1ed768d84fd79dba9709d608691f35468ad66f7818042590cce959e550b6f48b5afa704882da4d55f09126e422281ef1a7a892493fc69f27e
7
+ data.tar.gz: 55cb548f9c70e5562ffb9974b7f105b98be5da1af1da1129d52e738973cbd00a03b665e58137417799e4a38efb8b8f6d40fb6d08f1f0f2db129594774794b81d
data/Gemfile.lock CHANGED
@@ -1,22 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- logspot (0.2.0)
4
+ logspot (0.4.0)
5
5
  activesupport (>= 4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (4.1.8)
11
- i18n (~> 0.6, >= 0.6.9)
10
+ activesupport (4.2.0)
11
+ i18n (~> 0.7)
12
12
  json (~> 1.7, >= 1.7.7)
13
13
  minitest (~> 5.1)
14
- thread_safe (~> 0.1)
14
+ thread_safe (~> 0.3, >= 0.3.4)
15
15
  tzinfo (~> 1.1)
16
16
  diff-lcs (1.2.5)
17
- i18n (0.6.11)
18
- json (1.8.1)
19
- minitest (5.4.3)
17
+ i18n (0.7.0)
18
+ json (1.8.2)
19
+ minitest (5.5.1)
20
20
  rspec (3.1.0)
21
21
  rspec-core (~> 3.1.0)
22
22
  rspec-expectations (~> 3.1.0)
data/README.md CHANGED
@@ -0,0 +1,5 @@
1
+ #LoGspot
2
+
3
+ ```
4
+ LoGspot.new('/home/user/logs/production.log')
5
+ ```
@@ -1,7 +1,13 @@
1
1
  class LoGspot::Output::File
2
- def initialize(file_name)
3
- FileUtils.mkdir_p(File.dirname(file_name))
4
- @file = File.open(file_name, 'a')
2
+ def initialize(arg)
3
+ if arg.is_a?(String)
4
+ @physical = true
5
+ FileUtils.mkdir_p(File.dirname(arg))
6
+ @file = File.open(arg, 'a')
7
+ else
8
+ @physical = false
9
+ @file = arg
10
+ end
5
11
  end
6
12
 
7
13
  def puts(data)
@@ -10,10 +16,10 @@ class LoGspot::Output::File
10
16
  end
11
17
 
12
18
  def finalize
13
- @file.close
19
+ file.close if physical
14
20
  end
15
21
 
16
22
  private
17
23
 
18
- attr_reader :file
24
+ attr_reader :file, :physical
19
25
  end
data/lib/logspot.rb CHANGED
@@ -3,7 +3,7 @@ require_relative 'initialize'
3
3
  class LoGspot
4
4
  LOG_LEVELS = %w(DEBUG INFO WARN ERROR FATAL)
5
5
 
6
- def initialize(file_name, wrapper = nil)
6
+ def initialize(file_or_file_name = STDOUT, wrapper = nil)
7
7
  wrapper = ->(output, data) {
8
8
  base = "[#{Time.now.strftime('%Y/%m/%d %H:%M:%S')} #{level}] "
9
9
  if data[:space]
@@ -11,7 +11,7 @@ class LoGspot
11
11
  end
12
12
  output.puts(message: "#{base}#{data[:message]}")
13
13
  }
14
- @file = Output::File.new(file_name)
14
+ @file = Output::File.new(file_or_file_name)
15
15
  @output = @original_output = Output::Wrap.new(wrapper, @file)
16
16
  @level = nil
17
17
  end
data/logspot.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logspot'
3
- s.version = '0.3.0'
3
+ s.version = '0.4.0'
4
4
  s.authors = ['Tetsuri Moriya']
5
5
  s.email = ['tetsuri.moriya@gmail.com']
6
6
  s.summary = 'Logger'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logspot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tetsuri Moriya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-25 00:00:00.000000000 Z
11
+ date: 2015-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec