peastash 0.2.5 → 0.2.6
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 +4 -4
- data/README.md +2 -0
- data/lib/peastash/log_device.rb +5 -0
- data/lib/peastash/outputs/io.rb +10 -0
- data/lib/peastash/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7bf5afe018f224b34756bf038a5c4c09c0b798b63d492798e8a62221d873a08
|
4
|
+
data.tar.gz: 744cb15f8c32f8488daaed99f5134d8495986a999eb6bfd71cb6e978869e4019
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf1bec64ffc74f0acd056530b90d68e74c7e514d5b77541445bdc573bf6a8113be12ef13e447f1803d76d756a7c1a72774391a972e638b3143f0f6085a7e4f34
|
7
|
+
data.tar.gz: 99b5fe4a860fa4171db5f695454e77c5eeffbbff8e3b44e309663e85fee24a7afccce478a12dd6e82062bf528c692657bd1c75bf2f405ed2d0dfbc568daad47d
|
data/README.md
CHANGED
@@ -69,6 +69,8 @@ If the argument is a path to a non-writeable file, Peastash will attempt to dele
|
|
69
69
|
Peastash can easily be extended to output to any target.
|
70
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.
|
71
71
|
|
72
|
+
In case the directory doesn't exist, peastash won't crash, a tempfile will be created in /tmp (or $TMPDIR) and the data will be stored in this file. The full path of this tempfile will be printed to STDERR so it can easily be retrieved.
|
73
|
+
|
72
74
|
### What if I want to use it in my rack app?
|
73
75
|
|
74
76
|
There's a middleware for that! Simply add the following somewhere:
|
data/lib/peastash/log_device.rb
CHANGED
@@ -10,6 +10,11 @@ class Peastash
|
|
10
10
|
STDERR.puts "[#{Time.now}][#{Process.pid}] Could not open #{filename} for writing, recreating it. Info: #{stat_data.inspect}"
|
11
11
|
FileUtils.rm(filename)
|
12
12
|
create_logfile(filename)
|
13
|
+
rescue Errno::ENOENT => e
|
14
|
+
require 'tempfile'
|
15
|
+
temp_file = Tempfile.new([filename, '.log'])
|
16
|
+
STDERR.puts "[#{Time.now}][#{Process.pid}] Could not open #{filename} for writing: #{e.message}. Data will be writen in: #{temp_file.path}"
|
17
|
+
open_logfile(temp_file.path)
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
data/lib/peastash/outputs/io.rb
CHANGED
@@ -10,6 +10,16 @@ class Peastash
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def initialize(file, *args)
|
13
|
+
if file.is_a?(String)
|
14
|
+
# Rewrite symlink path to realpath for instance
|
15
|
+
# /home/app/releases/20190528155050/log/logstash.log -> /home/app/shared/log/logstash.log
|
16
|
+
# if the symlinked folder gets deleted on further releases, the log rotation will fail with
|
17
|
+
# a long wait ending with : log rotation inter-process lock failed.
|
18
|
+
# realpath is called without the filename because it expects the full path to exists
|
19
|
+
dir = File.realpath(File.dirname(file))
|
20
|
+
name = File.basename(file)
|
21
|
+
file = "#{dir}/#{name}"
|
22
|
+
end
|
13
23
|
@device = ::Peastash::LogDevice.new(file, *args)
|
14
24
|
end
|
15
25
|
|
data/lib/peastash/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Boisard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-event
|