systemd journal watcher daemon in ruby
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
570 B

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