Logging & Html

Posted by Dhai on Wed 21 Dec 2005 06:06 AM — 3 posts, 14,997 views.

#0
Here's my setup. I have a trigger that matches on the first two lines I get when connecting to my mud. I'm constantly logging, and I prefer logging in Colour & Html, and because of this I can't really use just one file to log to. Instead, I have it so I log to a .html file with a modified os.date() filename, so the "/"'s and ":"'s are replaced with "-"'s.

Anyway.

When I do an OpenLog to a .html file, I don't get any line breaks or anything. Even when I have the "HTML" checkbox in Logging checked. It's also only when I double-click the file (i.e., open it up in Opera or Internet Explorer). If I open up the .html in Notepad or Wordpad, the breaks are still there, and it looks fine (unless I've got the Colour HTML logging on).

Also, the files haven't got the black background I get when having an "Automatically log to this file" file, in HTML.

I have examples of all these situations, and can host them up so you can see what I'm talking about, if necessary.

Thanks.
Australia Forum Administrator #1
It's not clear exactly what the problem is here. You are talking about "not getting" line breaks, but you do if opened in Opera.

Anyway, I am guessing the problem is this:

If you do "auto log" there is a default log file preamble and postamble, that you can get by hitting a button in the log file preferences. Amongst other things, this puts a <pre> tag into the file, which means that lines are shown "as is" including line breaks.

Now with the OpenLog function, it assumed that if you wanted a preamble you would put it there yourself. For example, if you are appending to an existing file you probably don't.

If I am right, you simply need to output the log file preamble, after opening the log file. It is readly available by doing GetInfo:

http://www.gammon.com.au/scripts/doc.php?function=GetInfo

You want selector 11 (log file preamble), and 12 (log file postamble) for when you close the log file.

Simply get that string, and write it to the log file after opening it.
#2
Great, it's working.

Thanks a lot!