# HG changeset patch # User Kim Alvefur # Date 1431975050 -7200 # Node ID 60c692828cf60ab34699df23b47491d1fd3e3e77 # Parent 03afecdf2e3c8f0e2b6d628f09e9574b0a17baf2 hostmanager: Metatable with __tostring on hosts diff -r 03afecdf2e3c -r 60c692828cf6 core/hostmanager.lua --- a/core/hostmanager.lua Fri May 15 15:32:39 2015 +0200 +++ b/core/hostmanager.lua Mon May 18 20:50:50 2015 +0200 @@ -26,9 +26,23 @@ local pairs, select, rawget = pairs, select, rawget; local tostring, type = tostring, type; +local setmetatable = setmetatable; module "hostmanager" +local host_mt = { } +function host_mt:__tostring() + if self.type == "component" then + local typ = configmanager.get(self.host, "component_module"); + if typ == "component" then + return ("Component %q"):format(self.host); + end + return ("Component %q %q"):format(self.host, typ); + elseif self.type == "local" then + return ("VirtualHost %q"):format(self.host); + end +end + local hosts_loaded_once; local function load_enabled_hosts(config) @@ -76,6 +90,7 @@ send = host_send; modules = {}; }; + setmetatable(host_session, host_mt); if not host_config.component_module then -- host host_session.type = "local"; host_session.sessions = {};