logatron 0.2.3 → 0.2.4
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/logatron/configuration.rb +3 -4
- data/lib/logatron/logatron.rb +0 -2
- data/lib/logatron/railtie.rb +10 -14
- data/logatron.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9fed786239c01a5346c6e93e7c2656bf5ae4616
|
4
|
+
data.tar.gz: eb0340cb109e2ae9ad88e401530d827b47961269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d65d820bfbfa99b60884afdad5eb8650aa96b4daa0cef62fe7d5a37e4db398bf29a6990d9026a2b6208c9bcf5c56758f21811b1fe512277a7f7a814c3c72896
|
7
|
+
data.tar.gz: 7b0c58a3d2f17315d980c5e72999fcd763ab964eadc56abb70245a14443fa91284b5572fcef4f445522c1f2039d4ae473d0a33c7d689559434a4050b2f0644e2
|
data/Gemfile.lock
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'logger'
|
2
2
|
require 'logatron/const'
|
3
3
|
require 'logatron/basic_formatter'
|
4
4
|
require 'active_support/backtrace_cleaner'
|
@@ -15,7 +15,6 @@ module Logatron
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
18
|
def self.configure
|
20
19
|
self.configuration
|
21
20
|
yield(configuration)
|
@@ -26,7 +25,7 @@ module Logatron
|
|
26
25
|
attr_reader :loggable_levels, :backtrace_cleaner
|
27
26
|
|
28
27
|
def initialize
|
29
|
-
@logger =
|
28
|
+
@logger = Logger.new(STDOUT)
|
30
29
|
|
31
30
|
@transformer = proc {|x| x.to_json}
|
32
31
|
@host = `hostname`.chomp
|
@@ -45,7 +44,7 @@ module Logatron
|
|
45
44
|
end
|
46
45
|
|
47
46
|
def logger=(logger)
|
48
|
-
level = @logger.level
|
47
|
+
level = @logger.level
|
49
48
|
@logger = logger
|
50
49
|
@logger.level = level
|
51
50
|
@logger.formatter = Logatron::BasicFormatter.new
|
data/lib/logatron/logatron.rb
CHANGED
data/lib/logatron/railtie.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'lograge' # if this is an error for you, add 'lograge' to your bundle (left out of this gem's gemspec to keep dependencies down)
|
2
|
-
|
2
|
+
require 'syslog/logger'
|
3
3
|
module Syslog
|
4
4
|
class Logger
|
5
|
-
|
5
|
+
alias log add
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -11,11 +11,12 @@ module Logatron
|
|
11
11
|
def initialize(app)
|
12
12
|
@app = app
|
13
13
|
end
|
14
|
+
|
14
15
|
def call(env)
|
15
16
|
request = ActionDispatch::Request.new(env)
|
16
17
|
if request.headers['X-Ascent-Log-Id']
|
17
18
|
Logatron.msg_id = request.headers['X-Ascent-Log-Id']
|
18
|
-
elsif env['rack.session'].nil?
|
19
|
+
elsif env['rack.session'].nil? || env['rack.session']['warden.user.user.key'].nil?
|
19
20
|
Logatron.msg_id = SecureRandom.uuid + '-id-anonymous'
|
20
21
|
else
|
21
22
|
Logatron.msg_id = SecureRandom.uuid + '-id-' + env['rack.session']['warden.user.user.key'][0][0].to_s
|
@@ -25,24 +26,19 @@ module Logatron
|
|
25
26
|
end
|
26
27
|
|
27
28
|
class Railtie < Rails::Railtie
|
28
|
-
|
29
29
|
initializer 'logatron.configure_rails_initialization' do |app|
|
30
|
-
|
31
30
|
if defined?(Warden::Manager)
|
32
31
|
app.middleware.insert_before(Warden::Manager, Logatron::Middleware)
|
33
32
|
else
|
34
33
|
app.middleware.use Logatron::Middleware
|
35
34
|
end
|
36
|
-
|
37
35
|
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
config.lograge.logger = Logatron.configuration.logger
|
38
|
+
config.lograge.enabled = true
|
39
|
+
config.lograge.formatter = Lograge::Formatters::Json.new
|
40
|
+
config.lograge.custom_options = lambda do |event|
|
41
|
+
{ source: event.payload[:ip], severity: Logatron::INFO, site: Logatron.site, timestamp: Time.now.iso8601, host: Logatron.configuration.host, id: Logatron.msg_id }
|
42
|
+
end
|
46
43
|
end
|
47
|
-
|
48
44
|
end
|
data/logatron.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logatron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Grimes
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|