Hopefully inert commit to clean up logging across a number of modules, removing all...
authorMatthew Wild <mwild1@gmail.com>
Mon, 23 Jul 2012 16:32:33 +0000 (17:32 +0100)
committerMatthew Wild <mwild1@gmail.com>
Mon, 23 Jul 2012 16:32:33 +0000 (17:32 +0100)
core/rostermanager.lua
core/s2smanager.lua
core/sessionmanager.lua
plugins/adhoc/adhoc.lib.lua
plugins/mod_admin_adhoc.lua
plugins/mod_component.lua
plugins/mod_dialback.lua
plugins/mod_posix.lua
plugins/mod_presence.lua
plugins/mod_s2s/mod_s2s.lua
util/datamanager.lua

index 59ba6579a24af27fe78470de5473bb4ff1347698..524b61be7f3b174c5be4b3a4fa5962a810a1b998 100644 (file)
@@ -83,15 +83,15 @@ end
 
 function load_roster(username, host)
        local jid = username.."@"..host;
-       log("debug", "load_roster: asked for: "..jid);
+       log("debug", "load_roster: asked for: %s", jid);
        local user = bare_sessions[jid];
        local roster;
        if user then
                roster = user.roster;
                if roster then return roster; end
-               log("debug", "load_roster: loading for new user: "..username.."@"..host);
+               log("debug", "load_roster: loading for new user: %s@%s", username, host);
        else -- Attempt to load roster for non-loaded user
-               log("debug", "load_roster: loading for offline user: "..username.."@"..host);
+               log("debug", "load_roster: loading for offline user: %s@%s", username, host);
        end
        local data, err = datamanager.load(username, host, "roster");
        roster = data or {};
@@ -99,7 +99,7 @@ function load_roster(username, host)
        if not roster[false] then roster[false] = { broken = err or nil }; end
        if roster[jid] then
                roster[jid] = nil;
-               log("warn", "roster for "..jid.." has a self-contact");
+               log("warn", "roster for %s has a self-contact", jid);
        end
        if not err then
                hosts[host].events.fire_event("roster-load", username, host, roster);
@@ -108,7 +108,7 @@ function load_roster(username, host)
 end
 
 function save_roster(username, host, roster)
-       log("debug", "save_roster: saving roster for "..username.."@"..host);
+       log("debug", "save_roster: saving roster for %s@%s", username, host);
        if not roster then
                roster = hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster;
                --if not roster then
@@ -238,7 +238,7 @@ function set_contact_pending_out(username, host, jid) -- subscribe
                roster[jid] = item;
        end
        item.ask = "subscribe";
-       log("debug", "set_contact_pending_out: saving roster; set "..username.."@"..host..".roster["..jid.."].ask=subscribe");
+       log("debug", "set_contact_pending_out: saving roster; set %s@%s.roster[%q].ask=subscribe", username, host, jid);
        return save_roster(username, host, roster);
 end
 function unsubscribe(username, host, jid)
index 5fe3a3751d909ae0f357d45840b28ae202b4a980..ece90e8f39ae91bf2443c966108b5bbb982c3314 100644 (file)
@@ -87,7 +87,7 @@ function mark_connected(session)
        
        local from, to = session.from_host, session.to_host;
        
-       session.log("info", session.direction.." s2s connection "..from.."->"..to.." complete");
+       session.log("info", "%s s2s connection %s->%s complete", session.direction, from, to);
 
        local event_data = { session = session };
        if session.type == "s2sout" then
@@ -105,7 +105,7 @@ function mark_connected(session)
        
        if session.direction == "outgoing" then
                if sendq then
-                       session.log("debug", "sending "..#sendq.." queued stanzas across new outgoing connection to "..session.to_host);
+                       session.log("debug", "sending %d queued stanzas across new outgoing connection to %s", #sendq, session.to_host);
                        for i, data in ipairs(sendq) do
                                send(data[1]);
                                sendq[i] = nil;
index bd9255a2c7ec4bfe7d1c1fb3b0be8cbfeb9f7ae8..f542c02149b01a4c4dcef804988863c02b505cec 100644 (file)
@@ -38,7 +38,7 @@ function new_session(conn)
                getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end;
        end
        open_sessions = open_sessions + 1;
-       log("debug", "open sessions now: ".. open_sessions);
+       log("debug", "open sessions now: %d", open_sessions);
        
        local filter = initialize_filters(session);
        local w = conn.write;
index f951017233e661fb843d015fbcb8788ba87ff5e1..acdae6b9705604b83745901320a04f143cb8cac5 100644 (file)
@@ -65,8 +65,8 @@ function _M.handle_cmd(command, origin, stanza)
                                if (action == "prev") or (action == "next") or (action == "complete") then
                                        actions:tag(action):up();
                                else
-                                       module:log("error", 'Command "'..command.name..
-                                               '" at node "'..command.node..'" provided an invalid action "'..action..'"');
+                                       module:log("error", "Command %q at node %q provided an invalid action %q",
+                                               command.name, command.node, action);
                                end
                        end
                        cmdtag:add_child(actions);
index ee89d84fbb0da8be3153db98fb9ddea81ba458b4..016eeb4ac681ea182862a2568e8137d051131fc5 100644 (file)
@@ -63,15 +63,14 @@ function add_user_command_handler(self, data, state)
                                return { status = "completed", error = { message = "Account already exists" } };
                        else
                                if usermanager_create_user(username, fields.password, host) then
-                                       module:log("info", "Created new account " .. username.."@"..host);
+                                       module:log("info", "Created new account %s@%s", username, host);
                                        return { status = "completed", info = "Account successfully created" };
                                else
                                        return { status = "completed", error = { message = "Failed to write data to disk" } };
                                end
                        end
                else
-                       module:log("debug", (fields.accountjid or "<nil>") .. " " .. (fields.password or "<nil>") .. " "
-                               .. (fields["password-verify"] or "<nil>"));
+                       module:log("debug", "Invalid data, password mismatch or empty username while creating account for %s", fields.accountjid or "<nil>");
                        return { status = "completed", error = { message = "Invalid data.\nPassword mismatch, or empty username" } };
                end
        else
@@ -143,10 +142,10 @@ function delete_user_command_handler(self, data, state)
                for _, aJID in ipairs(fields.accountjids) do
                        local username, host, resource = jid.split(aJID);
                        if (host == data.to) and  usermanager_user_exists(username, host) and disconnect_user(aJID) and usermanager_create_user(username, nil, host) then
-                               module:log("debug", "User " .. aJID .. " has been deleted");
+                               module:log("debug", "User %s has been deleted", aJID);
                                succeeded[#succeeded+1] = aJID;
                        else
-                               module:log("debug", "Tried to delete non-existant user "..aJID);
+                               module:log("debug", "Tried to delete non-existant user %s", aJID);
                                failed[#failed+1] = aJID;
                        end
                end
@@ -165,7 +164,7 @@ function disconnect_user(match_jid)
        local sessions = host.sessions[node] and host.sessions[node].sessions;
        for resource, session in pairs(sessions or {}) do
                if not givenResource or (resource == givenResource) then
-                       module:log("debug", "Disconnecting "..node.."@"..hostname.."/"..resource);
+                       module:log("debug", "Disconnecting %s@%s/%s", node, hostname, resource);
                        session:close();
                end
        end
index 738124cccf54678c2e207a6ccf4a18edfa23f193..4037ad285af21b590314a3dede23bce61e380725 100644 (file)
@@ -124,7 +124,7 @@ local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
 
 function stream_callbacks.error(session, error, data, data2)
        if session.destroyed then return; end
-       module:log("warn", "Error processing component stream: "..tostring(error));
+       module:log("warn", "Error processing component stream: %s", tostring(error));
        if error == "no-stream" then
                session:close("invalid-namespace");
        elseif error == "parse-error" then
index 67be15e33bda6ecb7ed17a7758ed7b6fbcd0ea55..73a799e99c50a7a4b59985f9211907208b54a770 100644 (file)
@@ -102,7 +102,6 @@ module:hook("stanza/jabber:server:dialback:verify", function(event)
        if origin.type == "s2sout_unauthed" or origin.type == "s2sout" then
                local attr = stanza.attr;
                local dialback_verifying = dialback_requests[attr.from.."/"..(attr.id or "")];
-               module:log("debug", tostring(dialback_verifying).." "..attr.from.." "..origin.to_host);
                if dialback_verifying and attr.from == origin.to_host then
                        local valid;
                        if attr.type == "valid" then
@@ -110,7 +109,7 @@ module:hook("stanza/jabber:server:dialback:verify", function(event)
                                valid = "valid";
                        else
                                -- Warn the original connection that is was not verified successfully
-                               log("warn", "authoritative server for "..(attr.from or "(unknown)").." denied the key");
+                               log("warn", "authoritative server for %s denied the key", attr.from or "(unknown)");
                                valid = "invalid";
                        end
                        if not dialback_verifying.sends2s then
index 1670ac9586642b752b3e60ff451005aff369aef5..db594ccc753ca0c2acd306ff54b2bd7a048a0d0c 100644 (file)
@@ -34,19 +34,19 @@ module:hook("server-started", function ()
                if gid then
                        local success, msg = pposix.setgid(gid);
                        if success then
-                               module:log("debug", "Changed group to "..gid.." successfully.");
+                               module:log("debug", "Changed group to %s successfully.", gid);
                        else
-                               module:log("error", "Failed to change group to "..gid..". Error: "..msg);
-                               prosody.shutdown("Failed to change group to "..gid);
+                               module:log("error", "Failed to change group to %s. Error: %s", gid, msg);
+                               prosody.shutdown("Failed to change group to %s", gid);
                        end
                end
                if uid then
                        local success, msg = pposix.setuid(uid);
                        if success then
-                               module:log("debug", "Changed user to "..uid.." successfully.");
+                               module:log("debug", "Changed user to %s successfully.", uid);
                        else
-                               module:log("error", "Failed to change user to "..uid..". Error: "..msg);
-                               prosody.shutdown("Failed to change user to "..uid);
+                               module:log("error", "Failed to change user to %s. Error: %s", uid, msg);
+                               prosody.shutdown("Failed to change user to %s", uid);
                        end
                end
        end);
index 09a6f9f264ee6efcd2720b056666654b83f7dc8d..3cac09736d5abdda92aac2d0c60fd212c625128d 100644 (file)
@@ -160,7 +160,7 @@ function send_presence_of_available_resources(user, host, jid, recipient_session
                        end
                end
        end
-       log("debug", "broadcasted presence of "..count.." resources from "..user.."@"..host.." to "..jid);
+       log("debug", "broadcasted presence of %d resources from %s@%s to %s", count, user, host, jid);
        return count;
 end
 
@@ -169,7 +169,7 @@ function handle_outbound_presence_subscriptions_and_probes(origin, stanza, from_
        if to_bare == from_bare then return; end -- No self contacts
        local st_from, st_to = stanza.attr.from, stanza.attr.to;
        stanza.attr.from, stanza.attr.to = from_bare, to_bare;
-       log("debug", "outbound presence "..stanza.attr.type.." from "..from_bare.." for "..to_bare);
+       log("debug", "outbound presence %s from %s for %s", stanza.attr.type, from_bare, to_bare);
        if stanza.attr.type == "probe" then
                stanza.attr.from, stanza.attr.to = st_from, st_to;
                return;
@@ -214,7 +214,7 @@ function handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_b
        local node, host = jid_split(to_bare);
        local st_from, st_to = stanza.attr.from, stanza.attr.to;
        stanza.attr.from, stanza.attr.to = from_bare, to_bare;
-       log("debug", "inbound presence "..stanza.attr.type.." from "..from_bare.." for "..to_bare);
+       log("debug", "inbound presence %s from %s for %s", stanza.attr.type, from_bare, to_bare);
        
        if stanza.attr.type == "probe" then
                local result, err = rostermanager.is_contact_subscribed(node, host, from_bare);
index 16a8b4611035f95a6d1022fa913197bdb9abaa70..314be3f07e874db100bb006ce0e156cf1da6de38 100644 (file)
@@ -99,7 +99,7 @@ function route_to_existing_session(event)
                                log("error", "We are going to send from %s instead of %s", tostring(host.from_host), tostring(from_host));
                        end
                        if host.sends2s(stanza) then
-                               host.log("debug", "stanza sent over "..host.type);
+                               host.log("debug", "stanza sent over %s", host.type);
                                return true;
                        end
                end
index a5d676cc4be22d31375df8486880a39a802d189c..30c1e29812f77c1ff893a0ad1fd311374bd7c6bd 100644 (file)
@@ -115,18 +115,18 @@ function load(username, host, datastore)
        if not data then
                local mode = lfs.attributes(getpath(username, host, datastore), "mode");
                if not mode then
-                       log("debug", "Assuming empty "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+                       log("debug", "Assuming empty %s storage ('%s') for user: %s@%s", datastore, ret, username or "nil", host or "nil");
                        return nil;
                else -- file exists, but can't be read
                        -- TODO more detailed error checking and logging?
-                       log("error", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+                       log("error", "Failed to load %s storage ('%s') for user: %s@%s", datastore, ret, username or "nil", host or "nil");
                        return nil, "Error reading storage";
                end
        end
        setfenv(data, {});
        local success, ret = pcall(data);
        if not success then
-               log("error", "Unable to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+               log("error", "Unable to load %s storage ('%s') for user: %s@%s", datastore, ret, username or "nil", host or "nil");
                return nil, "Error reading storage";
        end
        return ret;
@@ -145,7 +145,7 @@ function store(username, host, datastore, data)
        -- save the datastore
        local f, msg = io_open(getpath(username, host, datastore, nil, true), "w+");
        if not f then
-               log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..(username or "nil").."@"..(host or "nil"));
+               log("error", "Unable to write to %s storage ('%s') for user: %s@%s", datastore, msg, username or "nil", host or "nil");
                return nil, "Error saving to storage";
        end
        f:write("return ");
@@ -166,7 +166,7 @@ function list_append(username, host, datastore, data)
        -- save the datastore
        local f, msg = io_open(getpath(username, host, datastore, "list", true), "a+");
        if not f then
-               log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..(username or "nil").."@"..(host or "nil"));
+               log("error", "Unable to write to %s storage ('%s') for user: %s@%s", datastore, msg, username or "nil", host or "nil");
                return;
        end
        f:write("item(");
@@ -184,7 +184,7 @@ function list_store(username, host, datastore, data)
        -- save the datastore
        local f, msg = io_open(getpath(username, host, datastore, "list", true), "w+");
        if not f then
-               log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..(username or "nil").."@"..(host or "nil"));
+               log("error", "Unable to write to %s storage ('%s') for user: %s@%s", datastore, msg, username or "nil", host or "nil");
                return;
        end
        for _, d in ipairs(data) do
@@ -207,11 +207,11 @@ function list_load(username, host, datastore)
        if not data then
                local mode = lfs.attributes(getpath(username, host, datastore, "list"), "mode");
                if not mode then
-                       log("debug", "Assuming empty "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+                       log("debug", "Assuming empty %s storage ('%s') for user: %s@%s", datastore, ret, username or "nil", host or "nil");
                        return nil;
                else -- file exists, but can't be read
                        -- TODO more detailed error checking and logging?
-                       log("error", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+                       log("error", "Failed to load %s storage ('%s') for user: %s@%s", datastore, ret, username or "nil", host or "nil");
                        return nil, "Error reading storage";
                end
        end
@@ -219,7 +219,7 @@ function list_load(username, host, datastore)
        setfenv(data, {item = function(i) t_insert(items, i); end});
        local success, ret = pcall(data);
        if not success then
-               log("error", "Unable to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+               log("error", "Unable to load %s storage ('%s') for user: %s@%s", datastore, ret, username or "nil", host or "nil");
                return nil, "Error reading storage";
        end
        return items;