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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29fe6dd6fca5b0294e9f55388615d6d8b58885a2f1898682525d19f239bd4552
4
- data.tar.gz: f5495f46f7a6473edbe7a1e4973f9ac021213eb121dd149f5b50d23d191ab9dc
3
+ metadata.gz: ca69ec750626ef4b6a76e40dcfb19bc1a9334410ee60b2714c611afb21a804c6
4
+ data.tar.gz: 1ec3c97e0aac9f04452606c1af507c7102aac37033a8c371841435dcd152c6c7
5
5
  SHA512:
6
- metadata.gz: 1345db77124853df14e65a3bfb5680b7936de5711cc0f21449d172822e8f44981a500b03cc29a072781039e4692cfc544e63387d817fa1eb65c4ea55995d83c3
7
- data.tar.gz: f63ed3284d529d6df4f76f3e885d1c52d6d7dbba024ee08c61fcce8e79e0b8f3e04c1a4d15c7c7de7f017568a3ffea0c0cdd9c4da7f649b38172317abf735a09
6
+ metadata.gz: aecbebf1fe2fdb3a9341ac6c0e9704bb8c20161ffb3c76fc11d2de386345a6f8d4d96cd103e97dc115e1b290d9f63144ae130984626e53d87b2b91feadf0b7f3
7
+ data.tar.gz: 01cab4c0d493f3b9ae5a884338121f1b758838709050e375c8d85a433bae129e9cb7d5c8ccd0664f8afa9a4fe99b3f8ad1513ee6b53f6853b745233cc18795ee
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.1
1
+ 0.14.0
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: betterlog 0.13.1 ruby lib
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.13.1"
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-20"
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]
@@ -2,6 +2,7 @@ require 'tins/xt'
2
2
  require 'json'
3
3
  require 'logger'
4
4
  require 'time'
5
+ require 'complex_config'
5
6
  require 'term/ansicolor'
6
7
 
7
8
  module Betterlog
@@ -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 : ::Logger.new(STDERR)
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.
@@ -2,6 +2,7 @@ module Betterlog
2
2
  class Log
3
3
  class EventFormatter
4
4
  include Term::ANSIColor
5
+ include ComplexConfig::Provider::Shortcuts
5
6
 
6
7
  def initialize(event)
7
8
  @event = event
@@ -1,6 +1,7 @@
1
1
  module Betterlog
2
2
  class LogEventFormatter < ActiveSupport::Logger::Formatter
3
3
  include ActiveSupport::TaggedLogging::Formatter
4
+ include ComplexConfig::Provider::Shortcuts
4
5
 
5
6
  def emitter
6
7
  'legacy'
@@ -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
- y.yield @redis.getrange(name_tmp, s, s + chunk_size - 1)
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
@@ -1,6 +1,6 @@
1
1
  module Betterlog
2
2
  # Betterlog version
3
- VERSION = '0.13.1'
3
+ VERSION = '0.14.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
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.13.1
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-20 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar