From 76c241495b189230eccaebfbdb40cbb0ab185299 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 2 Nov 2007 17:49:14 -0300 Subject: [PATCH] Add an option to dump debug information into a file for statuds_mpd. --- default/cfg_statusbar.lua | 3 +++ statusd_mpd.lua | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/default/cfg_statusbar.lua b/default/cfg_statusbar.lua index d13c2c7..0dffce3 100644 --- a/default/cfg_statusbar.lua +++ b/default/cfg_statusbar.lua @@ -118,6 +118,9 @@ mod_statusbar.launch_statusd{ -- escape for the percent character: %% template = "%title by %artist, track %num from %album, %year " .. "(%pos/%len) [%volume]", + + -- output debug filename (false or nil for no debug output) + debug = false, }, -- Memory monitor diff --git a/statusd_mpd.lua b/statusd_mpd.lua index e64bfe5..0bf006b 100644 --- a/statusd_mpd.lua +++ b/statusd_mpd.lua @@ -42,7 +42,10 @@ local defaults={ -- escape for the percent character: %% -- a default template - template = "%artist - %num - %title (%pos / %len)" + template = "%artist - %num - %title (%pos / %len)", + + -- output debug filename (false or nil for no debug output) + debug = false, } local settings = table.join(statusd.get_config("mpd"), defaults) @@ -50,6 +53,7 @@ local settings = table.join(statusd.get_config("mpd"), defaults) local timer local last_volume local last_state +local debug_file -- Function for starting and restarting execution of a process @@ -67,6 +71,13 @@ local function start_execution() while data do + -- debug + if settings.debug then + debug_file:write("ion-statusd [statusd_mpd]: DEBUG mpd data:\n" + .. data .. "\n\n") + debug_file:flush() + end + if not inited then -- welcome msg if string.sub(data, 1, 6) ~= "OK MPD" then @@ -184,6 +195,7 @@ end -- Now start execution of all defined processes +if settings.debug then debug_file = io.open("ion_statusd_mpd.log", "a+") end timer = statusd.create_timer() start_execution() -- 2.43.0