Skip to content
Snippets Groups Projects
  • Fons Rademakers's avatar
    7a5add34
    From Gerri: · 7a5add34
    Fons Rademakers authored
    This patch contains two new very small utility classes:
    
      1. base/inc/TRedirectOutputGuard.h
    
         Very simple guard class for RedirectOutput (similar to TLockGuard)
         to redirect the output to a file. Usage:
    
         void redir() {
            TRedirectOutputGuard guard("/tmp/pippo.txt","w");
            Printf("Here we go ...");
            cout << "Me too!" << endl;
         }
    
         If the file does not exist it is created. The mode has the same meaning
         as in TSystem::RedirectOutput(). When the guard object goes out of scope
         the redirection is restored to stdout and stderr, this is exception
         safe.
    
      2. gui/inc/TGRedirectOutputGuard.h, gui/src/TGRedirectOutputGuard.cxx
    
         Same functionality but with a text frame window. Usage:
    
         #include "TGTextView.h"
    
         void guiredir(TGTextView *tv, const char *fout, const char *mode) {
            TGRedirectOutputGuard guard(tv, fout, mode);
            Printf("Here we go ...");
            cout << "Me too!" << endl;
         }
    
         where 'tv' is a TGTextView object initialized by the caller; optionally
         one can save the logs into a file.
    
    
    git-svn-id: http://root.cern.ch/svn/root/trunk@12928 27541ba8-7e3a-0410-8455-c3a389f83636
    7a5add34
    History
    From Gerri:
    Fons Rademakers authored
    This patch contains two new very small utility classes:
    
      1. base/inc/TRedirectOutputGuard.h
    
         Very simple guard class for RedirectOutput (similar to TLockGuard)
         to redirect the output to a file. Usage:
    
         void redir() {
            TRedirectOutputGuard guard("/tmp/pippo.txt","w");
            Printf("Here we go ...");
            cout << "Me too!" << endl;
         }
    
         If the file does not exist it is created. The mode has the same meaning
         as in TSystem::RedirectOutput(). When the guard object goes out of scope
         the redirection is restored to stdout and stderr, this is exception
         safe.
    
      2. gui/inc/TGRedirectOutputGuard.h, gui/src/TGRedirectOutputGuard.cxx
    
         Same functionality but with a text frame window. Usage:
    
         #include "TGTextView.h"
    
         void guiredir(TGTextView *tv, const char *fout, const char *mode) {
            TGRedirectOutputGuard guard(tv, fout, mode);
            Printf("Here we go ...");
            cout << "Me too!" << endl;
         }
    
         where 'tv' is a TGTextView object initialized by the caller; optionally
         one can save the logs into a file.
    
    
    git-svn-id: http://root.cern.ch/svn/root/trunk@12928 27541ba8-7e3a-0410-8455-c3a389f83636