Class: AiRootShield::Enterprise::SyslogChannel

Inherits:
Object
  • Object
show all
Defined in:
lib/ai_root_shield/enterprise/alert_system.rb

Overview

Syslog channel implementation

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ SyslogChannel

Returns a new instance of SyslogChannel.



362
363
364
# File 'lib/ai_root_shield/enterprise/alert_system.rb', line 362

def initialize(config)
  @config = config
end

Instance Method Details

#send_alert(alert) ⇒ Object



366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/ai_root_shield/enterprise/alert_system.rb', line 366

def send_alert(alert)
  return { success: false, error: "Syslog not available" } unless Syslog.opened?
  
  priority = map_severity_to_syslog(alert[:severity])
  message = format_syslog_message(alert)
  
  Syslog.log(priority, message)
  
  { success: true, channel: 'syslog', timestamp: Time.now.utc.iso8601 }
rescue StandardError => e
  { success: false, error: e.message, channel: 'syslog' }
end