From 3ff60e5490c8b782dbe103b7b60754468c6e5c9c Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 8 May 2015 20:02:15 +0200 Subject: improved output of nopsyncd 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) diff --git a/src/tcpserver.lua b/src/tcpserver.lua index 837bf4e..8fa6d0b 100644 --- a/src/tcpserver.lua +++ b/src/tcpserver.lua @@ -32,6 +32,8 @@ function init_server() assert(server:bind(cnf.tcp_host, cnf.tcp_port)) assert(server:listen(5)) + print("TCPServer: listening on " .. cnf.tcp_host .. ":" .. cnf.tcp_port) + return server end -- cgit v0.10.2