Class: Datadog::Logging::Logger::UserFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/logging/logger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ UserFormatter

Returns a new instance of UserFormatter.



13
14
15
# File 'lib/datadog/logging/logger.rb', line 13

def initialize(user)
  @user = user
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



11
12
13
# File 'lib/datadog/logging/logger.rb', line 11

def user
  @user
end

Class Method Details

.call(user) ⇒ Object



30
31
32
# File 'lib/datadog/logging/logger.rb', line 30

def self.call(user)
  new(user).call
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/datadog/logging/logger.rb', line 17

def call
  base = {
    id:       id,
    username: username,
    email:    email,
    role:     role
  }

  result = base.compact

  result.empty? ? nil : result
end