trifle-logs 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/trifle/logs/driver/file.rb +13 -13
- data/lib/trifle/logs/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: 3d80823ec892e044744fd5735b0fd9ad5666d064548e9cb17c0237c3a29a5361
|
4
|
+
data.tar.gz: d043aa96d573be03e1a4dcead50ac4d2f40efd360911e37cbcf7e8ccc1ee3976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e3fb6a9af3c50673010fe0856d3cfb8093b98c669979324ac80e7ae1ce56bdafcb5ea56236afa88cacdec4d7e3083c3b3e8042b8f0bc29fa58d06efe183d08c
|
7
|
+
data.tar.gz: 558f07d331c523767cb410b15bfd62e7ae298c93ec772cb3e9dc0e2a398e8bcc38338f01049bf0ad02f1778b0bf2922c5ca7e8b85c39b89f21ea05c59ffaf0d4
|
data/Gemfile.lock
CHANGED
@@ -8,32 +8,32 @@ module Trifle
|
|
8
8
|
class File
|
9
9
|
attr_accessor :path, :suffix, :read_size
|
10
10
|
|
11
|
-
def initialize(path:, suffix: '%Y/%m/%d', read_size:
|
11
|
+
def initialize(path:, suffix: '%Y/%m/%d', read_size: 100)
|
12
12
|
@path = path
|
13
13
|
@suffix = suffix
|
14
14
|
@read_size = read_size
|
15
|
-
@files = {}
|
16
15
|
end
|
17
16
|
|
18
17
|
def filename_for(namespace:)
|
19
18
|
"#{path}/#{namespace}/#{Time.now.strftime(suffix)}.log"
|
20
19
|
end
|
21
20
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
::File
|
27
|
-
|
28
|
-
|
21
|
+
def locked_file(namespace:, &block)
|
22
|
+
filename = filename_for(namespace: namespace)
|
23
|
+
FileUtils.mkdir_p(::File.dirname(filename))
|
24
|
+
::File.open(filename, 'a') do |file|
|
25
|
+
file.flock(::File::LOCK_EX)
|
26
|
+
block.call(file)
|
27
|
+
ensure
|
28
|
+
file.flock(::File::LOCK_UN)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def dump(message, namespace:)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
locked_file(namespace: namespace) do |file|
|
34
|
+
file.write("#{message}\n")
|
35
|
+
end
|
36
|
+
message
|
37
37
|
end
|
38
38
|
|
39
39
|
def search(namespace:, pattern:, file_loc: nil, direction: nil)
|
data/lib/trifle/logs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trifle-logs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jozef Vaclavik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|