diff options
Diffstat (limited to 'src/qlistener.lua')
-rw-r--r-- | src/qlistener.lua | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/qlistener.lua b/src/qlistener.lua index 2a44019..e111ac7 100644 --- a/src/qlistener.lua +++ b/src/qlistener.lua @@ -46,13 +46,13 @@ end function handle_now(timestamp, nowcart, nowlen) local results, err = rddb:getCartInfo(nowcart); if results == nil then - io.stderr:write("can't fetch cart info: " .. err .. "\n") + io.stderr:write("ERROR: can't fetch cart info: " .. err .. "\n") -- TODO: this error shouldn't be ignored!!!! else -- print(timestamp .. " Info: '" .. results.TITLE .. "' von '" .. results.ARTIST .. "' aus '" .. results.ALBUM .. "'") local ret, err = playlog:insertNowMusic(timestamp, nowcart, nowlen, results.TITLE, results.ARTIST, results.ALBUM) if ret == nil then - io.stderr:write("can't insert music info: " .. err .. "\n") + io.stderr:write("ERROR: can't insert music info: " .. err .. "\n") else pipe.signal(timestamp) end @@ -62,7 +62,7 @@ end function handle_message(msg) local timestamp, nowcart, nowlen, nextcart, nextlen = string.match(msg, "^(%d+) (%d+) (%d+) (%d+) (%d+)$"); if not timestamp or not nowcart or not nowlen or not nextcart or not nextlen then - io.stderr:write("ignoring malformed message\n") + io.stderr:write("WARN: ignoring malformed message\n") else nowcart = tonumber(nowcart) nowlen = tonumber(nowlen) @@ -82,29 +82,31 @@ function main_loop() if q == nil then q, err = mq.open(cnf.queue_name, "wo") if q == nil then - io.stderr:write("creation of message queue failed: " .. err .. "\n") + io.stderr:write("ERROR: creation of message queue failed: " .. err .. "\n") os.exit(1) end end local ret, err = playlog:init(cnf) if ret == nil then - io.stderr:write("creation of playlog failed: " .. err .. "\n") + io.stderr:write("ERROR: creation of playlog failed: " .. err .. "\n") os.exit(1) end last_cart = assert(playlog:getLastCart()) + print("PLAYLOG: connected to " .. cnf.playlog_db .. "@" .. cnf.playlog_host .. " with user '" .. cnf.playlog_user .. "'") local ret, err = rddb:init(cnf) if ret == nil then - io.stderr:write("opening rivendell db failed: " .. err .. "\n") + io.stderr:write("ERROR: opening rivendell db failed: " .. err .. "\n") playlog:close() os.exit(1) end + print("RDDB: connected to " .. cnf.rddb_db .. "@" .. cnf.rddb_host .. " with user '" .. cnf.rddb_user .. "'") while true do local msg, prio = mq.receive(q) if msg == nil then - io.stderr:write("recv error: " .. prio .. "\n") + io.stderr:write("ERROR mq.receive(): " .. prio .. "\n") rddb:close() playlog:close() os.exit(2) |