People,<br><br>Can anyone help me with this issue?<br><br>log.startLogging(open(logname,'w')<br>or <br>log.startLogging(open(logname,'w'), setStdout=True)<br><br>Both print the console output in the log. But nothing is displayed on console! So I get a empty console<br>
I would like to keep the console going also:<br><br>Precisely:<br>Console -> gets the print calls Not Happening <br>Log -> gets the print calls + log.msg calls Happening<br><br>
I understand that this might be a trivial issue, but I am not able to figure it out in the documentation available :(<br><br>Thanks for any help<br><br>Regards<br>Naman<br><br><div class="gmail_quote">On Wed, Nov 4, 2009 at 7:43 AM, naman jain <span dir="ltr"><<a href="mailto:namanvit@gmail.com">namanvit@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>Using log.startLogging(open(logname, 'w'), setStdout=False)<br>very well solves the issue.. of stdout remaining untouched and log.msg() calls going to log<br>
<br>Can we do this ?:<br>Log file gets -> both the log.msg() calls , the stdout +stderr<br>
console -> gets stdout +stderr as usual<br><br>Regards<br><font color="#888888">Naman</font><div><div></div><div class="h5"><br><br><br><div class="gmail_quote">On Fri, Oct 30, 2009 at 9:25 PM, David Bolen <span dir="ltr"><<a href="http://db3l.net" target="_blank">db3l.net</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>naman jain <<a href="mailto:namanvit@gmail.com" target="_blank">namanvit@gmail.com</a>> writes:<br>
<br>
> I wanted to log in a file and keep the console also going with it.<br>
<br>
</div>I can read this as either:<br>
<br>
* Keep file logs and stdout/console completely separate, or<br>
* File gets explicit logs and copies of stdout, but stdout also goes to<br>
console as well.<br>
<br>
The latter is something I'd more commonly do, but the former is what<br>
you explain further below with your rules.<br>
<div><br>
> I am using<br>
> log.startLogging(open(logname, 'w'))<br>
><br>
> whatever documentation I could find about this API, it suggested me to pass<br>
> setStdout=False(in order to keep stdout away from putting into log)<br>
> somewhere in the startlogging function.<br>
><br>
> Something like this I tried:<br>
> log.startLogging(sys.stdout,setStdout=False)<br>
<br>
</div>Why did you switch to sys.stdout here? While this will prevent<br>
sys.stdout and sys.stderr from being redirected, it will use<br>
sys.stdout for any log.msg() calls, so nothing would end up in your<br>
log file.<br>
<div><br>
> Doesnt help in solving the problem of getting both things:<br>
><br>
> Requirement:<br>
> log.msg("messageforlog") -> goes to log<br>
> print "message for console" -> goes to console<br>
><br>
> Could anyone give some ideas on this?<br>
<br>
</div>I think you had the right idea with setStdout, but changed more than<br>
just that when you tested it. If you use a call like<br>
log.startLogging(open(logname, 'w'), setStdout=False) I believe you'll<br>
get what you want. Only calls to log.msg() will go to the file, and<br>
stdout/stderr will be left unchanged.<br>
<br>
-- David<br>
<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br>
</div></div></blockquote></div><br>