Add error logs to celeryscript execution and schedule

pull/974/head
Connor Rigby 2019-09-12 13:21:55 -07:00
parent 72c30d5320
commit 3398deba2d
No known key found for this signature in database
GPG Key ID: 29A88B24B70456E0
3 changed files with 8 additions and 4 deletions

View File

@ -1,5 +1,6 @@
defmodule FarmbotCore.FarmEventWorker.SequenceEvent do
require Logger
require FarmbotCore.Logger
alias FarmbotCeleryScript.AST
alias FarmbotCore.{
Asset,
@ -32,7 +33,9 @@ defmodule FarmbotCore.FarmEventWorker.SequenceEvent do
def handle_info({FarmbotCeleryScript, {:scheduled_execution, scheduled_at, executed_at, result}}, state) do
status = case result do
:ok -> "ok"
{:error, reason} -> reason
{:error, reason} ->
FarmbotCore.Logger.error(2, "Event scheduled at #{scheduled_at} failed to execute: #{reason}")
reason
end
_ = Asset.add_execution_to_farm_event!(state.farm_event, %{
scheduled_at: scheduled_at,

View File

@ -58,7 +58,9 @@ defimpl FarmbotCore.AssetWorker, for: FarmbotCore.Asset.RegimenInstance do
def handle_info({FarmbotCeleryScript, {:scheduled_execution, scheduled_at, executed_at, result}}, state) do
status = case result do
:ok -> "ok"
{:error, reason} -> reason
{:error, reason} ->
FarmbotCore.Logger.error(2, "Regimen scheduled at #{scheduled_at} failed to execute: #{reason}")
reason
end
_ = Asset.add_execution_to_regimen_instance!(state.regimen_instance, %{
scheduled_at: scheduled_at,

View File

@ -147,8 +147,7 @@ defmodule FarmbotExt.AMQP.CeleryScriptChannel do
reply = JSON.encode!(result_ast)
AMQP.Basic.publish(state.chan, @exchange, "bot.#{state.jwt.bot}.from_device", reply)
msg = ["CeleryScript Error\n", reason]
Logger.error(msg)
FarmbotCore.Logger.error(2, "Failed to execute command: #{reason}")
{:noreply, %{state | rpc_requests: Map.delete(state.rpc_requests, ref)}}
nil ->