betterlog 0.13.1 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/betterlog.gemspec +3 -3
- data/lib/betterlog.rb +1 -0
- data/lib/betterlog/log.rb +5 -1
- data/lib/betterlog/log/event_formatter.rb +1 -0
- data/lib/betterlog/log_event_formatter.rb +1 -0
- data/lib/betterlog/logger.rb +11 -2
- data/lib/betterlog/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: ca69ec750626ef4b6a76e40dcfb19bc1a9334410ee60b2714c611afb21a804c6
|
4
|
+
data.tar.gz: 1ec3c97e0aac9f04452606c1af507c7102aac37033a8c371841435dcd152c6c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aecbebf1fe2fdb3a9341ac6c0e9704bb8c20161ffb3c76fc11d2de386345a6f8d4d96cd103e97dc115e1b290d9f63144ae130984626e53d87b2b91feadf0b7f3
|
7
|
+
data.tar.gz: 01cab4c0d493f3b9ae5a884338121f1b758838709050e375c8d85a433bae129e9cb7d5c8ccd0664f8afa9a4fe99b3f8ad1513ee6b53f6853b745233cc18795ee
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.14.0
|
data/betterlog.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: betterlog 0.
|
2
|
+
# stub: betterlog 0.14.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "betterlog".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.14.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["betterplace Developers".freeze]
|
11
|
-
s.date = "2020-07-
|
11
|
+
s.date = "2020-07-30"
|
12
12
|
s.description = "This library provides structure json logging for our rails projects".freeze
|
13
13
|
s.email = "developers@betterplace.org".freeze
|
14
14
|
s.executables = ["betterlog".freeze, "betterlog_pusher".freeze, "betterlog_sink".freeze]
|
data/lib/betterlog.rb
CHANGED
data/lib/betterlog/log.rb
CHANGED
@@ -7,12 +7,16 @@ require 'betterlog/log/severity'
|
|
7
7
|
module Betterlog
|
8
8
|
class Log
|
9
9
|
include Tins::SexySingleton
|
10
|
+
extend ComplexConfig::Provider::Shortcuts
|
10
11
|
|
11
12
|
class_attr_accessor :default_logger
|
12
13
|
self.default_logger = Logger.new(STDERR)
|
14
|
+
if level = cc.log.level?
|
15
|
+
default_logger.level = level
|
16
|
+
end
|
13
17
|
|
14
18
|
def logger
|
15
|
-
defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger :
|
19
|
+
defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger : self.class.default_logger
|
16
20
|
end
|
17
21
|
|
18
22
|
# Logs a message on severity info.
|
data/lib/betterlog/logger.rb
CHANGED
@@ -2,9 +2,15 @@ require 'redis'
|
|
2
2
|
|
3
3
|
module Betterlog
|
4
4
|
class Logger < ::Logger
|
5
|
+
include ComplexConfig::Provider::Shortcuts
|
6
|
+
|
5
7
|
def initialize(redis, shift_age = 0, shift_size = 1048576, name: nil, buffer_size: nil, **opts)
|
6
8
|
@redis = redis
|
7
9
|
@fallback = ::Logger.new(STDERR)
|
10
|
+
if level = cc.log.level?
|
11
|
+
self.level = level
|
12
|
+
@fallback.level = level
|
13
|
+
end
|
8
14
|
@name = name || self.class.name
|
9
15
|
@buffer_size = determine_buffer_size(buffer_size)
|
10
16
|
super(nil, shift_age, shift_size, **opts)
|
@@ -92,7 +98,9 @@ module Betterlog
|
|
92
98
|
s = 0
|
93
99
|
e = @redis.strlen(name_tmp) - 1
|
94
100
|
until s > e
|
95
|
-
|
101
|
+
range = @redis.getrange(name_tmp, s, s + chunk_size - 1)
|
102
|
+
range.force_encoding 'ASCII-8BIT'
|
103
|
+
y.yield range
|
96
104
|
s += chunk_size
|
97
105
|
end
|
98
106
|
|
@@ -115,9 +123,10 @@ module Betterlog
|
|
115
123
|
chunk_size > 0 or raise ArgumentError, 'chunk_size > 0 required'
|
116
124
|
Enumerator.new do |y|
|
117
125
|
buffer = ''
|
126
|
+
buffer.encode! 'ASCII-8BIT'
|
118
127
|
each_chunk(chunk_size: chunk_size) do |chunk|
|
119
128
|
buffer << chunk
|
120
|
-
buffer.gsub!(/\A(.*?#$/)/) do |line|
|
129
|
+
buffer.gsub!(/\A(.*?#$/)/n) do |line|
|
121
130
|
y.yield(line)
|
122
131
|
''
|
123
132
|
end
|
data/lib/betterlog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- betterplace Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|