Logic Machine Forum
Pushover/email error log - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Pushover/email error log (/showthread.php?tid=4277)



Pushover/email error log - PassivPluss - 01.10.2022

Hi
Is it possible to email/pushover error log whenever a new error logĀ  entry comes?


RE: Pushover/email error log - PassivPluss - 10.10.2022

Is it possible?


RE: Pushover/email error log - admin - 10.10.2022

What kind of errors do you want to catch? Errors from scripts?


RE: Pushover/email error log - PassivPluss - 10.10.2022

if error log gets a new entry, so I was thinking all new entries.


RE: Pushover/email error log - admin - 11.10.2022

Run this as a scheduled scripts that runs once every minute. Replace log call with email/pushover etc.
Code:
stmaxid = storage.get('errorsmaxid', 0)
dbmaxid = db:getone('SELECT MAX(id) FROM errors') or 0

if stmaxid == dbmaxid then
  return
elseif dbmaxid < stmaxid then
  stmaxid = 0
end

rows = db:getall('SELECT * FROM errors WHERE id>?', stmaxid)
for _, row in ipairs(rows) do
  stmaxid = math.max(stmaxid, row.id)

  errordate = os.date('%c', row.errortime)
  log(errordate, row.scriptname, row.errortext)
end

storage.set('errorsmaxid', stmaxid)



RE: Pushover/email error log - PassivPluss - 13.10.2022

Works perfect as alwaysSmile Thanks admin