peastash 0.1.1 → 0.2.1

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: 2c31fdf441872ec649cd7a254e3bd576134af546
4
- data.tar.gz: b6347e1597e517e7bc43c98a474e9385d82ba1b3
3
+ metadata.gz: 571c31d67c9ad7ddfaf9653838e188d6d71c1769
4
+ data.tar.gz: 9d1c5dd762ed5c82a2cf904299b08f34ea7e77e5
5
5
  SHA512:
6
- metadata.gz: 5a08d801ae12fbe85ffd62846d9c9f38fb1da6bcffd3836cc8cae0cdfd76c5557f93402810a708530741494e9a1c7d2b04ca4f028381194b6bbbe0c7c0faab33
7
- data.tar.gz: cd7ed53cea042d0a5959e95981c4e518bb7b64e0d35d63980ae6b7ec1e82ecbca5f892dd8394ee4e18e3bc8fd837759f7cd4650d4b4973b700fb64e82c0ae98a
6
+ metadata.gz: 8435dd2695781fe10774119e7d1ebd36563ddbe41c5f401883484cbd3996899456ab5fd75c67db83bfb52d4ab5a0c69a5ee1e66fed52a421bd7b4cc51f69d163
7
+ data.tar.gz: 458cd115a2715bf865ba6c008a09caed810ed501b43f60d62683d74c4424c18e4f086d42b8d20305a89a001b43dc2962526398ff75e677ed8c87870a9974929b
data/.gitignore CHANGED
@@ -2,6 +2,7 @@ coverage
2
2
  pkg
3
3
  .DS_STORE
4
4
  *.log
5
+ *.gem
5
6
  Gemfile.lock
6
7
  gemfiles/*.lock
7
8
  spec/dummy*/tmp
data/README.md CHANGED
@@ -64,6 +64,8 @@ Please note that this is a global setting and cannot be set per-instance.
64
64
  #### Outputs
65
65
 
66
66
  Peastash ships with a single output: ``Peastash::Outputs::IO``. It can be initialized either by passing it a path or an IO object.
67
+ If the argument is a path to a non-writeable file, Peastash will attempt to delete the file to re-create it with the proper permissions.
68
+
67
69
  Peastash can easily be extended to output to any target.
68
70
  Simply configure Peastash's output with an object that responds to the ``#dump`` method. This method will be called at the end of the ``#log`` block, with 1 argument: a ``LogStash::Event`` object that you will probably need to serialize to json.
69
71
 
@@ -0,0 +1,15 @@
1
+ require 'logger'
2
+ require 'fileutils'
3
+
4
+ class Peastash
5
+ class LogDevice < ::Logger::LogDevice
6
+ def open_logfile(filename)
7
+ super
8
+ rescue Errno::EACCES
9
+ stat_data = File.stat(filename) rescue nil
10
+ STDERR.puts "[#{Time.now}][#{Process.pid}] Could not open #{filename} for writing, recreating it. Info: #{stat_data.inspect}"
11
+ FileUtils.rm(filename)
12
+ create_logfile(filename)
13
+ end
14
+ end
15
+ end
@@ -1,4 +1,4 @@
1
- require 'logger'
1
+ require 'peastash/log_device'
2
2
 
3
3
  class Peastash
4
4
  module Outputs
@@ -10,7 +10,7 @@ class Peastash
10
10
  end
11
11
 
12
12
  def initialize(file)
13
- @device = Logger::LogDevice.new(file)
13
+ @device = ::Peastash::LogDevice.new(file)
14
14
  end
15
15
 
16
16
  def dump(event)
@@ -1,3 +1,3 @@
1
1
  class Peastash
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peastash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Boisard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2016-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-event
@@ -168,6 +168,7 @@ files:
168
168
  - gemfiles/Gemfile.rails-4.2.x
169
169
  - gemfiles/Gemfile.rails-head
170
170
  - lib/peastash.rb
171
+ - lib/peastash/log_device.rb
171
172
  - lib/peastash/middleware.rb
172
173
  - lib/peastash/outputs/io.rb
173
174
  - lib/peastash/rails_ext.rb
@@ -390,3 +391,4 @@ test_files:
390
391
  - spec/peastash/rails_ext/watch_spec.rb
391
392
  - spec/peastash_spec.rb
392
393
  - spec/spec_helper.rb
394
+ has_rdoc: