Class: Smplkit::Logging::SmplLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/logging/models.rb

Overview

A logger resource managed by the smplkit Logging service.

Attributes:

- id, name: identity
- resolved_level: effective level computed by the platform from
  environment overrides + log group inheritance
- level: explicit override (nil means inherit)
- service, environment: provenance
- log_group_id: parent log group, if any
- managed: whether the SDK should apply server-driven level changes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client = nil, name:, resolved_level:, id: nil, level: nil, service: nil, environment: nil, log_group_id: nil, managed: true, description: nil, created_at: nil, updated_at: nil) ⇒ SmplLogger

Returns a new instance of SmplLogger.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/smplkit/logging/models.rb', line 19

def initialize(client = nil, name:, resolved_level:, id: nil, level: nil,
               service: nil, environment: nil, log_group_id: nil,
               managed: true, description: nil, created_at: nil, updated_at: nil)
  @client = client
  @id = id
  @name = name
  @resolved_level = resolved_level
  @level = level
  @service = service
  @environment = environment
  @log_group_id = log_group_id
  @managed = managed
  @description = description
  @created_at = created_at
  @updated_at = updated_at
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def description
  @description
end

#environmentObject

Returns the value of attribute environment.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def environment
  @environment
end

#idObject

Returns the value of attribute id.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def id
  @id
end

#levelObject

Returns the value of attribute level.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def level
  @level
end

#log_group_idObject

Returns the value of attribute log_group_id.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def log_group_id
  @log_group_id
end

#managedObject

Returns the value of attribute managed.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def managed
  @managed
end

#nameObject

Returns the value of attribute name.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def name
  @name
end

#resolved_levelObject

Returns the value of attribute resolved_level.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def resolved_level
  @resolved_level
end

#serviceObject

Returns the value of attribute service.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def service
  @service
end

#updated_atObject

Returns the value of attribute updated_at.



16
17
18
# File 'lib/smplkit/logging/models.rb', line 16

def updated_at
  @updated_at
end

Instance Method Details

#_apply(other) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/smplkit/logging/models.rb', line 54

def _apply(other)
  @id = other.id
  @name = other.name
  @resolved_level = other.resolved_level
  @level = other.level
  @service = other.service
  @environment = other.environment
  @log_group_id = other.log_group_id
  @managed = other.managed
  @description = other.description
  @created_at = other.created_at
  @updated_at = other.updated_at
end

#deleteObject Also known as: delete!



47
48
49
50
51
# File 'lib/smplkit/logging/models.rb', line 47

def delete
  raise "SmplLogger was constructed without a client; cannot delete" if @client.nil?

  @client.delete(@id || @name)
end

#managed?Boolean

Returns:

  • (Boolean)


36
# File 'lib/smplkit/logging/models.rb', line 36

def managed? = !!@managed

#saveObject Also known as: save!



38
39
40
41
42
43
44
# File 'lib/smplkit/logging/models.rb', line 38

def save
  raise "SmplLogger was constructed without a client; cannot save" if @client.nil?

  updated = @client._update_logger(self)
  _apply(updated)
  self
end