Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#4 Output Log to browser - Needs line endings!

ALL
closed-later
Mirco Bauer
MAIN (11)
2
2003-04-25
2003-03-22
Stephen Edmonds
No

Me again :-)

While running this script with output to the browser, it
rapidly becomes clear that you missed something out
while designing. Here is a snipet from the output I get...

Mar 22 21:09:48 DEBUG_IRCMESSAGES:
received: "NOTICE AUTH :*** Looking up your
hostname" Mar 22 21:09:48
DEBUG_MESSAGEHANDLER: no method found
for "NOTICE" (notice) Mar 22 21:09:48
DEBUG_IRCMESSAGES: received: "NOTICE
AUTH :*** Checking Ident" Mar 22 21:09:48
DEBUG_MESSAGEHANDLER: no method found
for "NOTICE" (notice) Mar 22 21:09:48
DEBUG_IRCMESSAGES: received: "NOTICE
AUTH :*** Found your hostname" Mar 22 21:09:48
DEBUG_MESSAGEHANDLER: no method found
for "NOTICE" (notice) Mar 22 21:10:47
DEBUG_IRCMESSAGES: received: "NOTICE
AUTH :*** No ident response"

Call me a critic, but I like to have log entries on
seperate lines ;-) I made an addition to my existing
code which solved the problem, but I do not know how it
affects other types of logging (i.e. it works when using
output to browser, but I haven't tested it in logging to file
etc etc)

In my config file I only use
$irc->setDebug(SMARTIRC_DEBUG_ALL);
in relation to logging.

My Change made:

function log($level, $entry)
{
if (!($level & $this->_debug))
return;

if (substr($entry, -1) != "\n")
$entry .= "\n";

$formatedentry = date('M d H:i:s ').$entry;

switch ($this->_logdestination) {
case SMARTIRC_STDOUT:
echo($formatedentry.'<br>');
flush();
break;

I added the .'<br>' to the end of echo($formatedentry);

Discussion

  • Logged In: YES
    user_id=737158

    BTW, I noticed you used \n in the script to put new lines... If i
    look at the source code for the page everything is arranged
    nicely.

    However what you see in the browser window is lacking any
    form of new line. For some reason the browser is ignoring the
    \n characters.

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-22

    Logged In: YES
    user_id=598557

    I have to detect if the script is ran from a browser, then a
    <pre> before the output is enough.
    I didn't put a <br> in it because it would break the design
    running the script from CLI and also when logging to syslog...
    Usualy those log things are not made for showing to the
    enduser, they are only used during developing where I
    thought developer would use CLI instead of a browser....
    but it makes sense to detect if a browser is used...

    The browser is not showing the \n because its not a valid
    HTML command, so its ignored... by adding "<pre>" before the
    logoutput the browser will show the code as it is, without
    HTML interpretation...

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-22

    • milestone: --> ALL
    • labels: --> MAIN
    • assigned_to: nobody --> meebey
     
  • Mirco Bauer
    Mirco Bauer
    2003-03-26

    • status: open --> open-later
     
  • Mirco Bauer
    Mirco Bauer
    2003-03-26

    • priority: 5 --> 2
     
  • Mirco Bauer
    Mirco Bauer
    2003-04-08

    Logged In: YES
    user_id=598557

    CVS version got this now... please try it and tell me if the
    output is now ok with the browser...

     
  • Mirco Bauer
    Mirco Bauer
    2003-04-24

    • status: open-later --> pending-later
     
  • Mirco Bauer
    Mirco Bauer
    2003-04-25

    • status: pending-later --> closed-later