summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-dockerman/luasrc
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2020-07-30 15:42:08 +0200
committerFlorian Eckert <fe@dev.tdt.de>2020-08-11 12:55:36 +0200
commit6bd215fe82fd2ad737ac23d8d666896b67cb57ba (patch)
treed8c9e5708d4663bc8f2648f3af93b4bd185f3165 /applications/luci-app-dockerman/luasrc
parent1c879bbcc479a82a2f1479f5a080e937b5f9b44c (diff)
luci-app-dockerman: controller/dockerman: clean up action event generation
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'applications/luci-app-dockerman/luasrc')
-rw-r--r--applications/luci-app-dockerman/luasrc/controller/dockerman.lua18
1 files changed, 15 insertions, 3 deletions
diff --git a/applications/luci-app-dockerman/luasrc/controller/dockerman.lua b/applications/luci-app-dockerman/luasrc/controller/dockerman.lua
index 608fbf4b01..368664cae6 100644
--- a/applications/luci-app-dockerman/luasrc/controller/dockerman.lua
+++ b/applications/luci-app-dockerman/luasrc/controller/dockerman.lua
@@ -64,12 +64,24 @@ function action_events()
if events.code == 200 then
for _, v in ipairs(events.body) do
+ local date = "unknown"
+ if v and v.time then
+ date = os.date("%Y-%m-%d %H:%M:%S", v.time)
+ end
+
+ local name = v.Actor.Attributes.name or "unknown"
+ local action = v.Action or "unknown"
+
if v and v.Type == "container" then
- logs = (logs ~= "" and (logs .. "\n") or logs) .. "[" .. os.date("%Y-%m-%d %H:%M:%S", v.time) .."] "..v.Type.. " " .. (v.Action or "null") .. " Container ID:".. (v.Actor.ID or "null") .. " Container Name:" .. (v.Actor.Attributes.name or "null")
+ local id = v.Actor.ID or "unknown"
+ logs = logs .. string.format("[%s] %s %s Container ID: %s Container Name: %s\n", date, v.Type, action, id, name)
elseif v.Type == "network" then
- logs = (logs ~= "" and (logs .. "\n") or logs) .. "[" .. os.date("%Y-%m-%d %H:%M:%S", v.time) .."] "..v.Type.. " " .. v.Action .. " Container ID:"..( v.Actor.Attributes.container or "null" ) .. " Network Name:" .. (v.Actor.Attributes.name or "null") .. " Network type:".. v.Actor.Attributes.type or ""
+ local container = v.Actor.Attributes.container or "unknown"
+ local network = v.Actor.Attributes.type or "unknown"
+ logs = logs .. string.format("[%s] %s %s Container ID: %s Network Name: %s Network type: %s\n", date, v.Type, action, container, name, network)
elseif v.Type == "image" then
- logs = (logs ~= "" and (logs .. "\n") or logs) .. "[" .. os.date("%Y-%m-%d %H:%M:%S", v.time) .."] "..v.Type.. " " .. v.Action .. " Image:".. (v.Actor.ID or "null").. " Image Name:" .. (v.Actor.Attributes.name or "null")
+ local id = v.Actor.ID or "unknown"
+ logs = logs .. string.format("[%s] %s %s Image: %s Image name: %s\n", date, v.Type, action, id, name)
end
end
end