🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++.moderated
Article #7

Re: Re-Routing streams

#7
From: Diego Novillo
Date: Fri, 15 Dec 1995 08:10
38 lines
1624 bytes
X-Original-Date: 15 Dec 1995 05:47:10 GMT

lussier@aviator.cis.ufl.edu (Kyle Lussier) writes:

>How do I get re-route, or overload the standard streams to send output
>to somewhere else?  Specifically I want all messages to stderr to be
>sent to a file and all messages to stdout to be sent to a file.
>
Here's one way of doing it. I removed the various consistency checks you
may want to do (existence of the file, etc, etc):


#include <iostream.h>

ofstream     cout_file;

void  redirectOutput(String fname)
{

   cout_file.open(fname);
   cout = cout_file;
}


Hope this helps.

Diego.


--
Diego Novillo (diego@cs.ualberta.ca)    |      Dept of Computing Science
WWW http://web.cs.ualberta.ca/~diego    |          University of Alberta
Use 'finger' to get my PGP public key   |     Edmonton, Alberta - Canada

    [ comp.lang.c++.moderated is a moderated newsgroup.  Submit articles ]
    [  to <c++-submit@netlab.cs.rpi.edu>.  The moderation policy can be  ]
    [   retrieved from <http://netlab.cs.rpi.edu/~cppmods/guide.html>.   ]
    [    Moderators can be reached at: c++-request@netlab.cs.rpi.edu.    ]
Technical Details
Message-ID: <4arah4$8g8@netlab.cs.rpi.edu>
Path: arc1-ca.pugleaf.net!library.erc.clarkson.edu!rpi!not-for-mail
References: <4aq1ig$1u2@netlab.cs.rpi.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!library.erc.clarkson.edu!rpi!not-for-mail
From: diego@cs.ualberta.ca (Diego Novillo)
Newsgroups: comp.lang.c++.moderated,comp.lang.c++
Subject: Re: Re-Routing streams
Date: 15 Dec 1995 08:10:12 -0000
Organization: Computing Science, U of Alberta, Edmonton, Canada
Sender: cppmods@netlab.cs.rpi.edu
Approved: vandevod@cs.rpi.edu
Message-ID: <4arah4$8g8@netlab.cs.rpi.edu>
References: <4aq1ig$1u2@netlab.cs.rpi.edu>
NNTP-Posting-Host: netlab.cs.rpi.edu