How to log the output from the multiple telnet sessions to separate log file

manjunatha.mahalingappa at gmail.com manjunatha.mahalingappa at gmail.com
Sat Oct 17 13:19:48 EDT 2015


On Friday, October 16, 2015 at 11:06:24 PM UTC-7, Chris Angelico wrote:
> On Sat, Oct 17, 2015 at 4:47 PM,  <manjunatha.mahalingappa at gmail.com> wrote:
> > class Logger():
> >     def __init__(self,log):
> >         self.terminal = sys.stdout
> >         self.log = log
> >
> >     def write(self, message):
> >         self.terminal.write(message)
> >         self.log.write(message)
> >
> >
> >     for (dname, ip, port) in tuples :
> >                 sys.stdout =Logger(log)
> 
> Every time you construct a Logger, it snapshots the previous value of
> sys.stdout. By the time you've set them all up, sys.stdout is the last
> Logger created, which will chain to the one created previous to it,
> then the one before that, and finally to the actual console.
> 
> Do you need to use sys.stdout at all? It would be a lot easier to
> ignore stdout and just write your logs directly to files.
> 
> ChrisA


Hello ChrisA,

Thank you so much for the replay,  objective is to collect all terminal output, if we have any other option to do the same with out using  stdout your most welcome to suggest me. 

Regards
Manju



More information about the Python-list mailing list