Hi,
Using log.startLogging(open(logname, 'w'), setStdout=False)
very well solves the issue.. of stdout remaining untouched and log.msg() calls going to log
Can we do this ?:
Log file gets -> both the log.msg() calls , the stdout +stderr
console -> gets stdout +stderr as usual
Regards
Naman
naman jain <namanvit@gmail.com> writes:I can read this as either:
> I wanted to log in a file and keep the console also going with it.
* Keep file logs and stdout/console completely separate, or
* File gets explicit logs and copies of stdout, but stdout also goes to
console as well.
The latter is something I'd more commonly do, but the former is what
you explain further below with your rules.
Why did you switch to sys.stdout here? While this will prevent
> I am using
> log.startLogging(open(logname, 'w'))
>
> whatever documentation I could find about this API, it suggested me to pass
> setStdout=False(in order to keep stdout away from putting into log)
> somewhere in the startlogging function.
>
> Something like this I tried:
> log.startLogging(sys.stdout,setStdout=False)
sys.stdout and sys.stderr from being redirected, it will use
sys.stdout for any log.msg() calls, so nothing would end up in your
log file.
I think you had the right idea with setStdout, but changed more than
> Doesnt help in solving the problem of getting both things:
>
> Requirement:
> log.msg("messageforlog") -> goes to log
> print "message for console" -> goes to console
>
> Could anyone give some ideas on this?
just that when you tested it. If you use a call like
log.startLogging(open(logname, 'w'), setStdout=False) I believe you'll
get what you want. Only calls to log.msg() will go to the file, and
stdout/stderr will be left unchanged.
-- David
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python