Logging messages that play nicely with server tools
"Tim Mackinnon" <[email protected]> Thu, 18 Apr 2024 12:24:41 +0100
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <[email protected]> |
--===============2639224890409681027==
Content-Type: multipart/alternative;
boundary=8496525531fa48be90ba4c745cd7e3fc
--8496525531fa48be90ba4c745cd7e3fc
Content-Type: text/plain
Hi everyone - not strictly a seaside question - but as many of you deploy seaside on web servers, you may know what I'm talking about.
I have a Pharo image in one of the wonderful BA Docker containers, and it runs well - and the host I'm using will show the logs for you, so you can figure out what is going on... well that is if your logs come out properly (and of course, if it gets really hairy then you can get a VNC session onto the image and figure stuff out)
So logs are handy, and pharo these days has a nice headless mode that redirects the Transcript to stdout - and there are also a few decent logging frameworks as well.
But as most things go to the Transcript, and that goes to stdout - it should be good.
HOWEVER - flushing is the killer, as if things happen and the last thing goes wrong, but the output isn't flushed, then you aren't going to see it.
So my question is how to properly flush? And I'm sure I've read something about this before, but I can't find it.
>From memory, you often need to have a Transcript cr. to flush your last line.
BUT, most things in the pharo image seem to use "self crTrace:" these days, which is a cr to ensure the previous msg is separated from what you want to write, and then you write your line out. However, as there is no cr - you might not see it.
So I tried changing my stuff to use "self traceCr:" (which is in the image), and that still didn't seem to work - the last failing line wasn't being output. Worse still, its confusing, as many things in the image are using crTrace: and so you get intermingled messages, which are hard to decipher.
So I tried: Transcript cr; show: msg; flush
But that didn't seem to work (which I don't understand)
Eventually I did: Transcript show: msg; cr; flush
And this seems to ensure things do reliably get outputted - but I'm wondering if anyone can shed light on this areas?
Ideally I want to use: Transcript cr'; show: msg; flush.
But having said this - I do wonder if tools like Papertrail or Betterstack won't work with this as they want a full line of text to parse into syslog format (and so they need the cr to terminate a line).
Stef did mention on the Pharo list to check the Stdio class, which did mention an anomaly about doing a #sync after a #flush (which I've never heard of).
So I'm just wondering what all of you do for your seaside logging? Do you use some of the modern web based server tools like other web kids seem to do?
Tim
p.s. While I'm not using Seaside, I've been having quite a bit of fun playing with CodeParadise, which borrows ideas from Seaside but with its WebSocket approach and direct Dom manipulation seems a bit more modern (although its a bit bleeding edge)
--8496525531fa48be90ba4c745cd7e3fc
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE html><html><head><title></title><style type=3D"text/css">p.Mso=
Normal,p.MsoNoSpacing{margin:0}
p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>Hi everyon=
e - not strictly a seaside question - but as many of you deploy seaside =
on web servers, you may know what I'm talking about.<br></div><div><br><=
/div><div>I have a Pharo image in one of the wonderful BA Docker contain=
ers, and it runs well - and the host I'm using will show the logs for yo=
u, so you can figure out what is going on... well that is if your logs c=
ome out properly (and of course, if it gets really hairy then you can ge=
t a VNC session onto the image and figure stuff out)<br></div><div><br><=
/div><div>So logs are handy, and pharo these days has a nice headless mo=
de that redirects the Transcript to stdout - and there are also a few de=
cent logging frameworks as well.<br></div><div><br></div><div>But as mos=
t things go to the Transcript, and that goes to stdout - it should be go=
od. <br></div><div><br></div><div>HOWEVER - flushing is the killer,=
as if things happen and the last thing goes wrong, but the output isn't=
flushed, then you aren't going to see it.<br></div><div><br></div><div>=
So my question is how to properly flush? And I'm sure I've read somethin=
g about this before, but I can't find it.<br></div><div><br></div><div>F=
rom memory, you often need to have a Transcript cr. to flush=
your last line.<br></div><div><br></div><div>BUT, most things in the ph=
aro image seem to use "self crTrace:" these days, which is a=
cr to ensure the previous msg is separated from what you want to write,=
and then you write your line out. However, as there is no cr - yo=
u might not see it.<br></div><div><br></div><div>So I tried changing my =
stuff to use "self traceCr:" (which is in the image), and that still did=
n't seem to work - the last failing line wasn't being output. Worse stil=
l, its confusing, as many things in the image are using crTrace: and so =
you get intermingled messages, which are hard to decipher.<br></div><div=
><br></div><div>So I tried: Transcript cr; show: msg; flush<br></div><di=
v><br></div><div>But that didn't seem to work (which I don't understand)=
<br></div><div><br></div><div>Eventually I did: Transcript show: msg; cr=
; flush<br></div><div><br></div><div>And this seems to ensure things do =
reliably get outputted - but I'm wondering if anyone can shed light on t=
his areas?<br></div><div><br></div><div>Ideally I want to use: Transcrip=
t cr'; show: msg; flush.<br></div><div><br></div><div>But having said th=
is - I do wonder if tools like Papertrail or Betterstack won't work with=
this as they want a full line of text to parse into syslog format (and =
so they need the cr to terminate a line).<br></div><div><br></div><div>S=
tef did mention on the Pharo list to check the Stdio class, which did me=
ntion an anomaly about doing a #sync after a #flush (which I've never he=
ard of).<br></div><div><br></div><div>So I'm just wondering what all of =
you do for your seaside logging? Do you use some of the modern web based=
server tools like other web kids seem to do?<br></div><div><br></div><d=
iv>Tim<br></div><div><br></div><div>p.s. While I'm not using Seaside, I'=
ve been having quite a bit of fun playing with CodeParadise, which borro=
ws ideas from Seaside but with its WebSocket approach and direct Dom man=
ipulation seems a bit more modern (although its a bit bleeding edge)<br>=
</div><div><br></div></body></html>
--8496525531fa48be90ba4c745cd7e3fc--
--===============2639224890409681027==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
seaside mailing list -- [email protected]
To unsubscribe send an email to [email protected]
--===============2639224890409681027==--