auto_logger 0.1.1 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/Gemfile.lock +26 -13
- data/README.md +27 -3
- data/auto_logger.gemspec +5 -4
- data/lib/auto_logger.rb +15 -11
- data/lib/auto_logger/version.rb +1 -1
- metadata +31 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c7f51d8f2d708e675544564798a8d494fda2668780e994ec7da69ec087549b1d
|
4
|
+
data.tar.gz: 677853ea89d8f8ab5fc71edee5451b40fbfd37714e7adb9055eddcda32bfcb0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18db633851ae1906b20f33f2d76c863839bb68789077d0f85a8ce791654b97e2db6e94a347a8570500afc7d2a125afa215bc051cad3724a154c9935b662693b2
|
7
|
+
data.tar.gz: 60cdb6c581ddfb1b2dca3c78fdeecb3c2d458d393f60e478082f3ae83256fbc415e681d11fda78ac33924d090386fc8efb5994fd5d48b016c0dc3afce672ade9
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,33 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
auto_logger (0.1.
|
4
|
+
auto_logger (0.1.6)
|
5
5
|
activesupport
|
6
6
|
beautiful-log
|
7
|
-
logger
|
8
7
|
|
9
8
|
GEM
|
10
9
|
remote: https://rubygems.org/
|
11
10
|
specs:
|
12
|
-
activesupport (
|
11
|
+
activesupport (6.1.3)
|
13
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (>=
|
15
|
-
minitest (
|
16
|
-
tzinfo (~>
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
17
|
awesome_print (1.8.0)
|
18
18
|
beautiful-log (0.2.2)
|
19
19
|
awesome_print (~> 1.8.0)
|
20
20
|
colorize (~> 0.8.1)
|
21
|
+
byebug (11.1.3)
|
22
|
+
coderay (1.1.3)
|
21
23
|
colorize (0.8.1)
|
22
|
-
concurrent-ruby (1.
|
23
|
-
i18n (1.
|
24
|
+
concurrent-ruby (1.1.8)
|
25
|
+
i18n (1.8.9)
|
24
26
|
concurrent-ruby (~> 1.0)
|
25
|
-
|
27
|
+
logstash-event (1.2.02)
|
28
|
+
logstash-logger (0.26.1)
|
29
|
+
logstash-event (~> 1.2)
|
30
|
+
method_source (1.0.0)
|
26
31
|
minitest (5.11.3)
|
32
|
+
pry (0.13.1)
|
33
|
+
coderay (~> 1.1)
|
34
|
+
method_source (~> 1.0)
|
35
|
+
pry-byebug (3.9.0)
|
36
|
+
byebug (~> 11.0)
|
37
|
+
pry (~> 0.13.0)
|
27
38
|
rake (10.5.0)
|
28
|
-
|
29
|
-
|
30
|
-
|
39
|
+
tzinfo (2.0.4)
|
40
|
+
concurrent-ruby (~> 1.0)
|
41
|
+
zeitwerk (2.4.2)
|
31
42
|
|
32
43
|
PLATFORMS
|
33
44
|
ruby
|
@@ -35,8 +46,10 @@ PLATFORMS
|
|
35
46
|
DEPENDENCIES
|
36
47
|
auto_logger!
|
37
48
|
bundler (~> 1.16)
|
49
|
+
logstash-logger
|
38
50
|
minitest (~> 5.0)
|
51
|
+
pry-byebug
|
39
52
|
rake (~> 10.0)
|
40
53
|
|
41
54
|
BUNDLED WITH
|
42
|
-
1.
|
55
|
+
1.17.2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# AutoLogger
|
2
|
-
|
3
|
-
Status](https://travis-ci.org/BrandyMint/auto_logger.svg)](https://travis-ci.org/BrandyMint/auto_logger)
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/BrandyMint/auto_logger.svg)](https://travis-ci.org/BrandyMint/auto_logger)
|
4
4
|
|
5
5
|
Упрощяет подключение уникальных логгеров для модулей и классов. После
|
6
6
|
подключения в модуль или класс через `include AutoLogger` добавляет метод
|
@@ -26,7 +26,7 @@ Or install it yourself as:
|
|
26
26
|
## Usage
|
27
27
|
|
28
28
|
```
|
29
|
-
|
29
|
+
class SomeService
|
30
30
|
include AutoLogger
|
31
31
|
|
32
32
|
def perform
|
@@ -46,6 +46,30 @@ class PublicAPI::OrdersAPI < Grape::API
|
|
46
46
|
end
|
47
47
|
```
|
48
48
|
|
49
|
+
Usage in module context:
|
50
|
+
|
51
|
+
```
|
52
|
+
module Custom
|
53
|
+
extend AutoLogger
|
54
|
+
|
55
|
+
def self.perform
|
56
|
+
logger.info "Do..."
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
Custom.logger.info "Do.."
|
61
|
+
```
|
62
|
+
|
63
|
+
Setup custom logger:
|
64
|
+
|
65
|
+
```
|
66
|
+
AutoLogger.logger_builder = -> (tag, default_formatter) {
|
67
|
+
ActiveSupport::TaggedLogging
|
68
|
+
.new(LogStashLogger.new(type: :stdout))
|
69
|
+
.tagged(tag)
|
70
|
+
}
|
71
|
+
```
|
72
|
+
|
49
73
|
## Development
|
50
74
|
|
51
75
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/auto_logger.gemspec
CHANGED
@@ -34,9 +34,10 @@ Gem::Specification.new do |spec|
|
|
34
34
|
|
35
35
|
spec.add_runtime_dependency 'beautiful-log'
|
36
36
|
spec.add_runtime_dependency 'activesupport'
|
37
|
-
spec.add_runtime_dependency 'logger'
|
38
37
|
|
39
|
-
spec.add_development_dependency
|
40
|
-
spec.add_development_dependency
|
41
|
-
spec.add_development_dependency
|
38
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
39
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
40
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
41
|
+
spec.add_development_dependency 'pry-byebug'
|
42
|
+
spec.add_development_dependency 'logstash-logger'
|
42
43
|
end
|
data/lib/auto_logger.rb
CHANGED
@@ -28,14 +28,14 @@ require "auto_logger/named"
|
|
28
28
|
module AutoLogger
|
29
29
|
DEFAULT_LOG_DIR = './log'
|
30
30
|
|
31
|
-
mattr_accessor :log_dir
|
32
|
-
|
33
|
-
private
|
31
|
+
mattr_accessor :log_dir, :log_formatter, :logger_builder, :_cached_logger
|
34
32
|
|
35
33
|
def logger
|
36
|
-
|
34
|
+
_cached_logger ||= _build_auto_logger
|
37
35
|
end
|
38
36
|
|
37
|
+
private
|
38
|
+
|
39
39
|
# Логируем вместе с временем выполнения
|
40
40
|
#
|
41
41
|
def bm_log(message)
|
@@ -45,18 +45,18 @@ module AutoLogger
|
|
45
45
|
res
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
self.class.
|
48
|
+
def _auto_logger_tag
|
49
|
+
([Class, Module].include?(self.class) ? self.name : self.class.name).underscore.gsub('/','_')
|
50
50
|
end
|
51
51
|
|
52
52
|
def _auto_logger_file
|
53
|
-
file = "#{
|
53
|
+
file = "#{_auto_logger_tag}.log"
|
54
54
|
|
55
55
|
if log_dir.present?
|
56
56
|
File.join(log_dir, file)
|
57
57
|
|
58
58
|
elsif defined? Rails
|
59
|
-
Rails.root.join
|
59
|
+
Rails.root.join 'log', file
|
60
60
|
|
61
61
|
else
|
62
62
|
File.join(DEFAULT_LOG_DIR, file)
|
@@ -64,11 +64,15 @@ module AutoLogger
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def _log_formatter
|
67
|
-
!defined?(Rails) || Rails.env.test? ? Logger::Formatter.new : Formatter.new
|
67
|
+
@log_formatter || !defined?(Rails) || Rails.env.test? ? Logger::Formatter.new : Formatter.new
|
68
68
|
end
|
69
69
|
|
70
70
|
def _build_auto_logger
|
71
|
-
|
72
|
-
|
71
|
+
if logger_builder.nil?
|
72
|
+
ActiveSupport::Logger.new(_auto_logger_file).
|
73
|
+
tap { |logger| logger.formatter = _log_formatter }
|
74
|
+
else
|
75
|
+
logger_builder.call(_auto_logger_tag, _log_formatter)
|
76
|
+
end
|
73
77
|
end
|
74
78
|
end
|
data/lib/auto_logger/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danil Pismenny
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: beautiful-log
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: logger
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: bundler
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +80,34 @@ dependencies:
|
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '5.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: logstash-logger
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Mixin that adds `logger` method authomatically configured to use log
|
98
112
|
name from module/class
|
99
113
|
email:
|
@@ -137,8 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0'
|
139
153
|
requirements: []
|
140
|
-
|
141
|
-
rubygems_version: 2.6.14.1
|
154
|
+
rubygems_version: 3.0.3
|
142
155
|
signing_key:
|
143
156
|
specification_version: 4
|
144
157
|
summary: "'logger' method configured with class/module name"
|