Class: Bizside::AuditLog
- Inherits:
-
Object
- Object
- Bizside::AuditLog
- Defined in:
- lib/bizside/audit_log.rb
Constant Summary collapse
- @@ignore_paths =
[]
- @@truncate_length =
8192
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ AuditLog
constructor
A new instance of AuditLog.
Constructor Details
#initialize(app) ⇒ AuditLog
Returns a new instance of AuditLog.
21 22 23 |
# File 'lib/bizside/audit_log.rb', line 21 def initialize(app) @app = app end |
Class Method Details
.ignore_paths ⇒ Object
9 10 11 |
# File 'lib/bizside/audit_log.rb', line 9 def self.ignore_paths @@ignore_paths end |
.truncate_length ⇒ Object
13 14 15 |
# File 'lib/bizside/audit_log.rb', line 13 def self.truncate_length @@truncate_length end |
.truncate_length=(value) ⇒ Object
17 18 19 |
# File 'lib/bizside/audit_log.rb', line 17 def self.truncate_length=(value) @@truncate_length = value end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bizside/audit_log.rb', line 25 def call(env) start = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%3N%z') status, headers, response = @app.call(env) stop = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%3N%z') exception = env[Bizside::ShowExceptions::BIZSIDE_EXCEPTION_ENV_KEY] if env['BIZSIDE_SUPPRESS_AUDIT'] return status, headers, response end if @@ignore_paths.any? do |path| case path when Regexp env['REQUEST_URI'] =~ path else env['REQUEST_URI'] == path end end return status, headers, response end if Bizside.rails_env&.development? return status, headers, response if env['REQUEST_URI'] =~ /\/[^\/]+\/assets\/.*/ elsif Bizside.rails_env&.test? return status, headers, response end info = build_loginfo(env, start, stop, status, exception) logger.record(info) return status, headers, response end |