Monday, November 08, 2010 at 12:04 AM.

system.verbs.builtins.mainResponder.adminSite.website.httpLog

on httpLog (maxitems=200) {
	<<Changes
		<<8/2/02; 2:23:36 PM by JES
			<<Created.
	local (pta = html.getPageTableAddress ());
	pta^.title = "HTTP Server Log";
	local (colors = {pta^.trbg1, pta^.trbg2});
	local (columns = {"Time", "Code", "Threads", "Secs", "Size", "Client", "Host", "URL"});
	local (colsToAlignRight = {"Code", "Threads", "Secs", "Size"});
	on renderItemCallback (adritem) {
		local (itemtext = "");
		on add (s) {
			itemtext = itemtext + (s + "\r");};
		on td (s, align="") {
			if align != "" {
				align = " align=\"" + align + "\""};
			return ("<td" + align + " valign=\"top\"><font size=\"-1\" class=\"small\">" + s + "</font></td>")};
		with adritem^ {
			local (secsstring = "");
			try { //get ticks, expressed in a fraction of a second, it's complicated
				secsstring = string.ratio (ticks, 60, 2);
				if sizeOf (string.nthField (secsString, ".", 2)) == 1 {
					secsString = secsString + "0"};
				if ticks > 120 { //more than two seconds
					secsstring = "<b><font color=\"deeppink\">" + secsstring + "</font></b>"}};
			add (td (string.replaceAll (string.popLeading (string.nthField (time, ";", 2), ' '), " ", " ")));
			add (td (code, "right"));
			add (td (" " + threads + " ", "right"));
			add (td (" " + secsstring + " ", "right"));
			add (td (string.megabytestring (size), "right"));
			bundle { //add the member name, if we have it, otherwise do a DNS lookup
				if defined (member) {
					local (groupname = config.mainResponder.globals.defaultMembershipGroup);
					if defined (adritem^.group) {
						groupname = adritem^.group};
					local (link = mainResponder.members.linktomember (groupname, adritem^.member, urlprefix:"/memberProfile?g=[[group]]&m="));
					add (td (link))}
				else {
					local (client = xml.convertToDisplayName (nameof (adritem^)));
					try {client = tcp.dns.getDomainName (client)};
					if sizeof (client) > 35 {
						local (ctdots = 0, i);
						for i = sizeof (client) downto 1 {
							if client [i] == '.' {
								if ++ctdots == 2 {
									client = string.mid (client, i, sizeof (client));
									break}}}};
					add (td (client))}};
			bundle { //add the host and link
				local (link = "http://");
				if defined (host) {
					link = link + host}
				else {
					link = link + tcp.dns.getMyDomainName ()};
				add (td (host));
				link = link + url;
				if defined (pathargs) {
					if pathargs != "" {
						link = link + "$" + pathargs}};
				if defined (searchargs) {
					if searchargs != "" {
						link = link + "?" + searchargs}};
				add (td ("<a href=\"" + link + "\">" + url + "</a>"))};
			bundle { //add the referrer
				if defined (referrer) {
					add (td ("<a href=\"" + referrer + "\">*</a>"))}
				else {
					add (td (" "))}}};
		return (itemtext)};
	local (ctitems);
	local (logtext = mainResponder.log.browseAny ("mainResponder", @renderItemCallback, colors, columns, 3, maxitems, colsToAlignRight, @ctitems));
	if ctitems {
		return (logtext)}
	else {
		return (logtext + "<p>There are no items to list at this time.</p>")}}
	<<return (mainResponder.log.browser (50, colors, "small", true, 12, false, maxitems))



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.