applicaster-logger 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1,2 @@
1
1
  require 'applicaster/logger'
2
+ require "applicaster/rack/request_uuid"
@@ -14,6 +14,9 @@ module Applicaster
14
14
  user_id: event.payload[:user_id],
15
15
  }
16
16
  end
17
+
18
+ app.middleware.insert_after ActionDispatch::RequestId,
19
+ Applicaster::Rack::RequestUuid
17
20
  end
18
21
 
19
22
  def self.setup_logger(app)
@@ -31,5 +34,18 @@ module Applicaster
31
34
  Applicaster::Logger::Formatter.new(facility: "delayed_job")
32
35
  end
33
36
  end
37
+
38
+ def self.with_request_uuid(uuid)
39
+ old, Thread.current[:logger_request_uuid] =
40
+ Thread.current[:logger_request_uuid], uuid
41
+
42
+ yield
43
+ ensure
44
+ Thread.current[:logger_request_uuid] = old
45
+ end
46
+
47
+ def self.current_request_uuid
48
+ Thread.current[:logger_request_uuid]
49
+ end
34
50
  end
35
51
  end
@@ -40,6 +40,11 @@ module Applicaster
40
40
  event[:host] ||= HOST
41
41
  event[:application] ||= Rails.application.config.applicaster_logger.application_name
42
42
  event[:environment] ||= Rails.env
43
+
44
+ if Applicaster::Logger.current_request_uuid
45
+ event[:request_uuid] ||= Applicaster::Logger.current_request_uuid
46
+ end
47
+
43
48
  default_fields.each do |field, value|
44
49
  event[field] ||= value
45
50
  end
@@ -1,5 +1,5 @@
1
1
  module Applicaster
2
2
  module Logger
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -0,0 +1,17 @@
1
+ module Applicaster
2
+ module Rack
3
+ class RequestUuid
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ request = ActionDispatch::Request.new(env)
10
+
11
+ Applicaster::Logger.with_request_uuid(request.uuid) do
12
+ @app.call(env)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: applicaster-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-01 00:00:00.000000000 Z
12
+ date: 2015-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logstash-logger
@@ -93,6 +93,7 @@ files:
93
93
  - lib/applicaster/logger/formatter.rb
94
94
  - lib/applicaster/logger/railtie.rb
95
95
  - lib/applicaster/logger/version.rb
96
+ - lib/applicaster/rack/request_uuid.rb
96
97
  homepage: ''
97
98
  licenses:
98
99
  - MIT