Re: [ROOT] redirection of output of Printf

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Tue Feb 25 2003 - 17:53:44 MET


Hi Hajime,

 there are two ways to redirect output. If it is to just redirect
TMinuit output after given a fit command you can do:

root [0] hist->Fit("gaus"); > fit.log

and all output generated by this command will be redirected to fit.log.
This works for any command executed via the ROOT/CINT command line.

If you want to programmatically redirect all stdio and iostream output
than that is a bit more complicated and involves the dup() and reopen()
of the right file descriptors. Example code for the last case can be
found in the TProofServ.cxx file.

Cheers, Fons.



On Tue, 2003-02-25 at 17:46, Hajime Nanjyo wrote:
> Dear Jiri,
> 
> Thank you.
> Printf is used inside the TMiniut class for the logging.
> I want to redirect the log.
> 
> In the source file of TMinuit.cxx, the possibility of the redirection is
> described as below.
> *-*   - The ROOT static function Printf is provided to replace all      *
> *-*     format statements and to print on currently defined output file.*
> 
> Anyway, I checked the TString.cxx.
> Inside the function of Printf(..), printf(..) is used.
> Now I also think the redireciton is impossible.
> ( The cout could be replaced by a fstream,
>   but I am not sure for the case of stdout for the printf.)
> 
> Best regards,
> Hajime
> 
> > 
> > Hi Hajime,
> > 
> > see base/src/TString.cxx for the implementation of Printf. I think it
> > cannot be redirected in an interactive session. You can use iostream
> > operators in combination with Form {cout << Form("aa%d",1) << endl;}
> > or with stringstream. 
> > cheers
> > 
> > Jiri
> 
> 
> 
> 
> > Hajime Nanjyo <nanjyo@icepp.s.u-tokyo.ac.jp> writes:
> > 
> > > Dear Rooters,
> > >
> > > I used the ROOT static function Printf and wanted 
> > > to redirect the output of Printf from the stdout to
> > > a file(i.e. to a fstream). Could you tell me how?
> > >
> > > By the way,which source code the implimentaion
> > > of Printf is writen?
> > >
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET