OPS - making a couple of modules much less noisy as the logs on a large mission get rather big

This commit is contained in:
Applevangelist 2021-12-14 13:40:16 +01:00
parent ea926f173a
commit d7801b59e7
3 changed files with 68 additions and 67 deletions

View File

@ -877,16 +877,16 @@ end
-- @param #number Formation Formation of the group.
function ARMYGROUP:onbeforeUpdateRoute(From, Event, To, n, N, Speed, Formation)
if self:IsWaiting() then
self:E(self.lid.."Update route denied. Group is WAIRING!")
self:T(self.lid.."Update route denied. Group is WAIRING!")
return false
elseif self:IsInUtero() then
self:E(self.lid.."Update route denied. Group is INUTERO!")
self:T(self.lid.."Update route denied. Group is INUTERO!")
return false
elseif self:IsDead() then
self:E(self.lid.."Update route denied. Group is DEAD!")
self:T(self.lid.."Update route denied. Group is DEAD!")
return false
elseif self:IsStopped() then
self:E(self.lid.."Update route denied. Group is STOPPED!")
self:T(self.lid.."Update route denied. Group is STOPPED!")
return false
elseif self:IsHolding() then
self:T(self.lid.."Update route denied. Group is holding position!")
@ -1030,7 +1030,7 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
-- Passed final WP ==> Full Stop
---
self:E(self.lid..string.format("WARNING: Passed final WP when UpdateRoute() ==> Full Stop!"))
self:T(self.lid..string.format("WARNING: Passed final WP when UpdateRoute() ==> Full Stop!"))
self:FullStop()
end
@ -1249,7 +1249,7 @@ function ARMYGROUP:onafterRTZ(From, Event, To, Zone, Formation)
end
else
self:E(self.lid.."ERROR: No RTZ zone given!")
self:T(self.lid.."ERROR: No RTZ zone given!")
end
end
@ -1385,7 +1385,7 @@ function ARMYGROUP:onbeforeEngageTarget(From, Event, To, Target)
local ammo=self:GetAmmoTot()
if ammo.Total==0 then
self:E(self.lid.."WARNING: Cannot engage TARGET because no ammo left!")
self:T(self.lid.."WARNING: Cannot engage TARGET because no ammo left!")
return false
end
@ -1683,7 +1683,7 @@ function ARMYGROUP:_InitGroup(Template)
-- Quick check.
if #units~=size0 then
self:E(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
self:T(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
end
-- Add elemets.
@ -1713,7 +1713,7 @@ function ARMYGROUP:SwitchFormation(Formation, Permanently, NoRouteUpdate)
if self:IsAlive() or self:IsInUtero() then
Formation=Formation or self.optionDefault.Formation
Formation=Formation or (self.optionDefault.Formation or "Off road")
Permanently = Permanently or false
if Permanently then
@ -1723,7 +1723,7 @@ function ARMYGROUP:SwitchFormation(Formation, Permanently, NoRouteUpdate)
end
-- Set current formation.
self.option.Formation=Formation
self.option.Formation=Formation or "Off road"
if self:IsInUtero() then
self:T(self.lid..string.format("Will switch formation to %s (permanently=%s) when group is spawned", self.option.Formation, tostring(Permanently)))

View File

@ -3254,7 +3254,7 @@ function AUFTRAG:onafterStatus(From, Event, To)
local chief=self.chief and self.statusChief or "N/A"
-- Info message.
self:I(self.lid..string.format("Status %s: Target=%s, T=%s-%s, assets=%d, groups=%d, targets=%d, legions=%d, commander=%s, chief=%s",
self:T(self.lid..string.format("Status %s: Target=%s, T=%s-%s, assets=%d, groups=%d, targets=%d, legions=%d, commander=%s, chief=%s",
self.status, targetname, Cstart, Cstop, #self.assets, Ngroups, Ntargets, Nlegions, commander, chief))
end
@ -3366,22 +3366,23 @@ function AUFTRAG:Evaluate()
end
-- Debug text.
local text=string.format("Evaluating mission:\n")
text=text..string.format("Own casualties = %d/%d\n", self.Ncasualties, self.Nelements)
text=text..string.format("Own losses = %.1f %%\n", owndamage)
text=text..string.format("Killed units = %d\n", self.Nkills)
text=text..string.format("--------------------------\n")
text=text..string.format("Targets left = %d/%d\n", Ntargets, Ntargets0)
text=text..string.format("Targets life = %.1f/%.1f\n", Life, Life0)
text=text..string.format("Enemy losses = %.1f %%\n", targetdamage)
text=text..string.format("--------------------------\n")
text=text..string.format("Success Cond = %s\n", tostring(successCondition))
text=text..string.format("Failure Cond = %s\n", tostring(failureCondition))
text=text..string.format("--------------------------\n")
text=text..string.format("Final Success = %s\n", tostring(not failed))
text=text..string.format("=========================")
self:I(self.lid..text)
if self.verbose > 0 then
local text=string.format("Evaluating mission:\n")
text=text..string.format("Own casualties = %d/%d\n", self.Ncasualties, self.Nelements)
text=text..string.format("Own losses = %.1f %%\n", owndamage)
text=text..string.format("Killed units = %d\n", self.Nkills)
text=text..string.format("--------------------------\n")
text=text..string.format("Targets left = %d/%d\n", Ntargets, Ntargets0)
text=text..string.format("Targets life = %.1f/%.1f\n", Life, Life0)
text=text..string.format("Enemy losses = %.1f %%\n", targetdamage)
text=text..string.format("--------------------------\n")
text=text..string.format("Success Cond = %s\n", tostring(successCondition))
text=text..string.format("Failure Cond = %s\n", tostring(failureCondition))
text=text..string.format("--------------------------\n")
text=text..string.format("Final Success = %s\n", tostring(not failed))
text=text..string.format("=========================")
self:I(self.lid..text)
end
if failed then
self:Failed()
else
@ -3735,7 +3736,7 @@ function AUFTRAG:OnEventUnitLost(EventData)
for _,_groupdata in pairs(self.groupdata) do
local groupdata=_groupdata --#AUFTRAG.GroupData
if groupdata and groupdata.opsgroup and groupdata.opsgroup.groupname==EventData.IniGroupName then
self:I(self.lid..string.format("UNIT LOST event for opsgroup %s unit %s", groupdata.opsgroup.groupname, EventData.IniUnitName))
self:T(self.lid..string.format("UNIT LOST event for opsgroup %s unit %s", groupdata.opsgroup.groupname, EventData.IniUnitName))
end
end
@ -3858,7 +3859,7 @@ function AUFTRAG:onafterAssetDead(From, Event, To, Asset)
-- Number of groups alive.
local N=self:CountOpsGroups()
self:I(self.lid..string.format("Asset %s dead! Number of ops groups remaining %d", tostring(Asset.spawngroupname), N))
self:T(self.lid..string.format("Asset %s dead! Number of ops groups remaining %d", tostring(Asset.spawngroupname), N))
-- All assets dead?
if N==0 then
@ -3892,7 +3893,7 @@ function AUFTRAG:onafterCancel(From, Event, To)
local Ngroups = self:CountOpsGroups()
-- Debug info.
self:I(self.lid..string.format("CANCELLING mission in status %s. Will wait for %d groups to report mission DONE before evaluation", self.status, Ngroups))
self:T(self.lid..string.format("CANCELLING mission in status %s. Will wait for %d groups to report mission DONE before evaluation", self.status, Ngroups))
-- Time stamp.
self.Tover=timer.getAbsTime()
@ -4010,13 +4011,13 @@ function AUFTRAG:onafterSuccess(From, Event, To)
local N=math.max(self.NrepeatSuccess, self.Nrepeat)
-- Repeat mission.
self:I(self.lid..string.format("Mission SUCCESS! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeated+1, N))
self:T(self.lid..string.format("Mission SUCCESS! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeated+1, N))
self:Repeat()
else
-- Stop mission.
self:I(self.lid..string.format("Mission SUCCESS! Number of max repeats %d reached ==> Stopping mission!", self.repeated+1))
self:T(self.lid..string.format("Mission SUCCESS! Number of max repeats %d reached ==> Stopping mission!", self.repeated+1))
self:Stop()
end
@ -4052,13 +4053,13 @@ function AUFTRAG:onafterFailed(From, Event, To)
local N=math.max(self.NrepeatFailure, self.Nrepeat)
-- Repeat mission.
self:I(self.lid..string.format("Mission FAILED! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeated+1, N))
self:T(self.lid..string.format("Mission FAILED! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeated+1, N))
self:Repeat()
else
-- Stop mission.
self:I(self.lid..string.format("Mission FAILED! Number of max repeats %d reached ==> Stopping mission!", self.repeated+1))
self:T(self.lid..string.format("Mission FAILED! Number of max repeats %d reached ==> Stopping mission!", self.repeated+1))
self:Stop()
end
@ -4185,7 +4186,7 @@ end
function AUFTRAG:onafterStop(From, Event, To)
-- Debug info.
self:I(self.lid..string.format("STOPPED mission in status=%s. Removing missions from queues. Stopping CallScheduler!", self.status))
self:T(self.lid..string.format("STOPPED mission in status=%s. Removing missions from queues. Stopping CallScheduler!", self.status))
-- TODO: Mission should be OVER! we dont want to remove running missions from any queues.

View File

@ -668,7 +668,7 @@ function FLIGHTGROUP:StartUncontrolled(delay)
self.group:StartUncontrolled(_delay)
self.isUncontrolled=false
else
self:E(self.lid.."ERROR: Could not start uncontrolled group as it is NOT alive!")
self:T(self.lid.."ERROR: Could not start uncontrolled group as it is NOT alive!")
end
end
@ -766,7 +766,7 @@ function FLIGHTGROUP:onbeforeStatus(From, Event, To)
if isdead then
local text=string.format("Element %s is dead at t=%.3f but has status %s! Maybe despawned without notice or landed at a too small airbase. Calling ElementDead in 60 sec to give other events a chance",
tostring(element.name), timer.getTime(), tostring(element.status))
self:E(self.lid..text)
self:T(self.lid..text)
self:__ElementDead(60, element)
end
@ -841,7 +841,7 @@ function FLIGHTGROUP:Status()
end
else
--self:E(self.lid..string.format("Element %s is in PARKING queue but has no parking spot assigned!", element.name))
--self:T(self.lid..string.format("Element %s is in PARKING queue but has no parking spot assigned!", element.name))
end
end
end
@ -957,7 +957,7 @@ function FLIGHTGROUP:Status()
end
-- Log outut.
self:I(self.lid..string.format("Travelled ds=%.1f km dt=%.1f s ==> v=%.1f knots. Fuel left for %.1f min", self.traveldist/1000, dt, UTILS.MpsToKnots(v), TmaxFuel/60))
self:T(self.lid..string.format("Travelled ds=%.1f km dt=%.1f s ==> v=%.1f knots. Fuel left for %.1f min", self.traveldist/1000, dt, UTILS.MpsToKnots(v), TmaxFuel/60))
end
@ -1897,10 +1897,10 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n, N)
self:T3(self.lid.."Update route possible. Group is ALIVE")
elseif self:IsDead() then
-- Group is dead! No more updates.
self:E(self.lid.."Update route denied. Group is DEAD!")
self:T(self.lid.."Update route denied. Group is DEAD!")
allowed=false
elseif self:IsInUtero() then
self:E(self.lid.."Update route denied. Group is INUTERO!")
self:T(self.lid.."Update route denied. Group is INUTERO!")
allowed=false
else
-- Not airborne yet. Try again in 5 sec.
@ -1923,19 +1923,19 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n, N)
-- Requested waypoint index <1. Something is seriously wrong here!
if n and n<1 then
self:E(self.lid.."Update route denied because waypoint n<1!")
self:T(self.lid.."Update route denied because waypoint n<1!")
allowed=false
end
-- No current waypoint. Something is serously wrong!
if not self.currentwp then
self:E(self.lid.."Update route denied because self.currentwp=nil!")
self:T(self.lid.."Update route denied because self.currentwp=nil!")
allowed=false
end
local Nn=n or self.currentwp+1
if not Nn or Nn<1 then
self:E(self.lid.."Update route denied because N=nil or N<1")
self:T(self.lid.."Update route denied because N=nil or N<1")
trepeat=-5
allowed=false
end
@ -1958,7 +1958,7 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n, N)
self:T2(self.lid.."Allowing update route for Task: Task_Land_At")
else
local taskname=task and task.description or "No description"
self:E(self.lid..string.format("WARNING: Update route denied because taskcurrent=%d>0! Task description = %s", self.taskcurrent, tostring(taskname)))
self:T(self.lid..string.format("WARNING: Update route denied because taskcurrent=%d>0! Task description = %s", self.taskcurrent, tostring(taskname)))
allowed=false
end
else
@ -2229,24 +2229,24 @@ function FLIGHTGROUP:onbeforeRTB(From, Event, To, airbase, SpeedTo, SpeedHold)
local Tsuspend=nil
if airbase==nil then
self:E(self.lid.."ERROR: Airbase is nil in RTB() call!")
self:T(self.lid.."ERROR: Airbase is nil in RTB() call!")
allowed=false
end
-- Check that coaliton is okay. We allow same (blue=blue, red=red) or landing on neutral bases.
if airbase and airbase:GetCoalition()~=self.group:GetCoalition() and airbase:GetCoalition()>0 then
self:E(self.lid..string.format("ERROR: Wrong airbase coalition %d in RTB() call! We allow only same as group %d or neutral airbases 0", airbase:GetCoalition(), self.group:GetCoalition()))
self:T(self.lid..string.format("ERROR: Wrong airbase coalition %d in RTB() call! We allow only same as group %d or neutral airbases 0", airbase:GetCoalition(), self.group:GetCoalition()))
return false
end
if self.currbase and self.currbase:GetName()==airbase:GetName() then
self:E(self.lid.."WARNING: Currbase is already same as RTB airbase. RTB canceled!")
self:T(self.lid.."WARNING: Currbase is already same as RTB airbase. RTB canceled!")
return false
end
-- Check if the group has landed at an airbase. If so, we lost control and RTBing is not possible (only after a respawn).
if self:IsLanded() then
self:E(self.lid.."WARNING: Flight has already landed. RTB canceled!")
self:T(self.lid.."WARNING: Flight has already landed. RTB canceled!")
return false
end
@ -2260,7 +2260,7 @@ function FLIGHTGROUP:onbeforeRTB(From, Event, To, airbase, SpeedTo, SpeedHold)
self.RTBRecallCount = self.RTBRecallCount+1
end
if self.RTBRecallCount>6 then
self:I(self.lid..string.format("WARNING: Group [%s] is not moving and was called RTB %d times. Assuming a problem and despawning!", self:GetState(), self.RTBRecallCount))
self:T(self.lid..string.format("WARNING: Group [%s] is not moving and was called RTB %d times. Assuming a problem and despawning!", self:GetState(), self.RTBRecallCount))
self.RTBRecallCount=0
self:Despawn(5)
return
@ -2274,25 +2274,25 @@ function FLIGHTGROUP:onbeforeRTB(From, Event, To, airbase, SpeedTo, SpeedHold)
local Ntot,Nsched, Nwp=self:CountRemainingTasks()
if self.taskcurrent>0 then
self:I(self.lid..string.format("WARNING: Got current task ==> RTB event is suspended for 10 sec"))
self:T(self.lid..string.format("WARNING: Got current task ==> RTB event is suspended for 10 sec"))
Tsuspend=-10
allowed=false
end
if Nsched>0 then
self:I(self.lid..string.format("WARNING: Still got %d SCHEDULED tasks in the queue ==> RTB event is suspended for 10 sec", Nsched))
self:T(self.lid..string.format("WARNING: Still got %d SCHEDULED tasks in the queue ==> RTB event is suspended for 10 sec", Nsched))
Tsuspend=-10
allowed=false
end
if Nwp>0 then
self:I(self.lid..string.format("WARNING: Still got %d WAYPOINT tasks in the queue ==> RTB event is suspended for 10 sec", Nwp))
self:T(self.lid..string.format("WARNING: Still got %d WAYPOINT tasks in the queue ==> RTB event is suspended for 10 sec", Nwp))
Tsuspend=-10
allowed=false
end
if self.Twaiting and self.dTwait then
self:I(self.lid..string.format("WARNING: Group is Waiting for a specific duration ==> RTB event is canceled", Nwp))
self:T(self.lid..string.format("WARNING: Group is Waiting for a specific duration ==> RTB event is canceled", Nwp))
allowed=false
end
@ -2305,7 +2305,7 @@ function FLIGHTGROUP:onbeforeRTB(From, Event, To, airbase, SpeedTo, SpeedHold)
return allowed
else
self:E(self.lid.."WARNING: Group is not alive! RTB call not allowed.")
self:T(self.lid.."WARNING: Group is not alive! RTB call not allowed.")
return false
end
@ -2361,35 +2361,35 @@ function FLIGHTGROUP:onbeforeLandAtAirbase(From, Event, To, airbase)
local Tsuspend=nil
if airbase==nil then
self:E(self.lid.."ERROR: Airbase is nil in LandAtAirase() call!")
self:T(self.lid.."ERROR: Airbase is nil in LandAtAirase() call!")
allowed=false
end
-- Check that coaliton is okay. We allow same (blue=blue, red=red) or landing on neutral bases.
if airbase and airbase:GetCoalition()~=self.group:GetCoalition() and airbase:GetCoalition()>0 then
self:E(self.lid..string.format("ERROR: Wrong airbase coalition %d in LandAtAirbase() call! We allow only same as group %d or neutral airbases 0", airbase:GetCoalition(), self.group:GetCoalition()))
self:T(self.lid..string.format("ERROR: Wrong airbase coalition %d in LandAtAirbase() call! We allow only same as group %d or neutral airbases 0", airbase:GetCoalition(), self.group:GetCoalition()))
return false
end
if self.currbase and self.currbase:GetName()==airbase:GetName() then
self:E(self.lid.."WARNING: Currbase is already same as LandAtAirbase airbase. LandAtAirbase canceled!")
self:T(self.lid.."WARNING: Currbase is already same as LandAtAirbase airbase. LandAtAirbase canceled!")
return false
end
-- Check if the group has landed at an airbase. If so, we lost control and RTBing is not possible (only after a respawn).
if self:IsLanded() then
self:E(self.lid.."WARNING: Flight has already landed. LandAtAirbase canceled!")
self:T(self.lid.."WARNING: Flight has already landed. LandAtAirbase canceled!")
return false
end
if self:IsParking() then
allowed=false
Tsuspend=-30
self:E(self.lid.."WARNING: Flight is parking. LandAtAirbase call delayed by 30 sec")
self:T(self.lid.."WARNING: Flight is parking. LandAtAirbase call delayed by 30 sec")
elseif self:IsTaxiing() then
allowed=false
Tsuspend=-1
self:E(self.lid.."WARNING: Flight is parking. LandAtAirbase call delayed by 1 sec")
self:T(self.lid.."WARNING: Flight is parking. LandAtAirbase call delayed by 1 sec")
end
if Tsuspend and not allowed then
@ -2398,7 +2398,7 @@ function FLIGHTGROUP:onbeforeLandAtAirbase(From, Event, To, airbase)
return allowed
else
self:E(self.lid.."WARNING: Group is not alive! LandAtAirbase call not allowed")
self:T(self.lid.."WARNING: Group is not alive! LandAtAirbase call not allowed")
return false
end
@ -2573,14 +2573,14 @@ function FLIGHTGROUP:onbeforeWait(From, Event, To, Duration, Altitude, Speed)
-- Check for a current task.
if self.taskcurrent>0 and not self:IsLandedAt() then
self:I(self.lid..string.format("WARNING: Got current task ==> WAIT event is suspended for 30 sec!"))
self:T(self.lid..string.format("WARNING: Got current task ==> WAIT event is suspended for 30 sec!"))
Tsuspend=-30
allowed=false
end
-- Check for a current transport assignment.
if self.cargoTransport and not self:IsLandedAt() then
--self:I(self.lid..string.format("WARNING: Got current TRANSPORT assignment ==> WAIT event is suspended for 30 sec!"))
--self:T(self.lid..string.format("WARNING: Got current TRANSPORT assignment ==> WAIT event is suspended for 30 sec!"))
--Tsuspend=-30
--allowed=false
end
@ -2803,7 +2803,7 @@ function FLIGHTGROUP:onafterEngageTarget(From, Event, To, Target)
DCStask=self:GetGroup():TaskCombo(DCSTasks)
else
self:E("ERROR: unknown Target in EngageTarget! Needs to be a UNIT, STATIC, GROUP, SET_UNIT or SET_GROUP")
self:T("ERROR: unknown Target in EngageTarget! Needs to be a UNIT, STATIC, GROUP, SET_UNIT or SET_GROUP")
return
end
@ -3094,7 +3094,7 @@ function FLIGHTGROUP:_InitGroup(Template)
-- Quick check.
if #units~=size0 then
self:E(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
self:T(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
end
-- Add elemets.
@ -3893,7 +3893,7 @@ function FLIGHTGROUP:GetParking(airbase)
-- No parking spot for at least one asset :(
if not gotit then
self:E(self.lid..string.format("WARNING: No free parking spot for element %s", element.name))
self:T(self.lid..string.format("WARNING: No free parking spot for element %s", element.name))
return nil
end