systemd journal watcher daemon in ruby
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
604 B

  1. require 'pry'
  2. module JournaldWatcher
  3. class Mailer
  4. def initialize(from, to, subject)
  5. @from = from
  6. @to = to
  7. @subject = subject
  8. end
  9. def mail_entry(entry)
  10. subject = entry.message
  11. if subject.length > 50
  12. subject = subject[0..50] + '...'
  13. end
  14. msg = Mail.new
  15. msg.to = @to
  16. msg.from = @from
  17. msg.subject = "#{@subject} #{subject}"
  18. msg.body = entry.message
  19. msg.add_file filename: 'data.json', content: entry.to_h.to_json
  20. binding.pry
  21. # msg.deliver
  22. end
  23. end
  24. end