How to log dcmnet level info

All other questions regarding DCMTK

Moderator: Moderator Team

Message
Author
st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

#16 Post by st80rules »

Uli Schlachter wrote:
This does work as expected, however redirecting the output via ">>" doesn't work, because the output happens on stderr and not on stdout. If you want to redirect stderr, use "2>>".
Thanks Uli,

that did it!

I still don't get it, because when I tried findscu with the normal redirect I got a full log in the output file.

Normand

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#17 Post by Jörg Riesmeier »

The difference is probably that findscu calls prepareCmdLineArgs() and your program does not:

Code: Select all

void prepareCmdLineArgs(int& /* argc */, char** /* argv */,
                        const char* /* progname */)
{
#ifdef _WIN32
#ifndef DCMTK_GUI
#ifndef __CYGWIN__
    /* Map stderr onto stdout (cannot redirect stderr under windows).
     * Remove any buffering (windows uses a 2k buffer for stdout when not
     * writing to the console.  since dcmtk uses mixed stdout, stderr
     * cout and cerr, this results in _very_ mixed up output).
     */

    /* duplicate the stderr file descriptor be the same as stdout */
    close(fileno(stderr));
    int fderr = dup(fileno(stdout));
    if (fderr != fileno(stderr))
    {
        char buf[256];
        DCMDATA_ERROR("INTERNAL ERROR: cannot map stderr to stdout: "
            << OFStandard::strerror(errno, buf, sizeof(buf)));
    }

#ifndef NO_IOS_BASE_ASSIGN
    /* make cout refer to cerr. This does not work with all iostream implementations :-( */
    cout = cerr;
#endif

    /* make stdout the same as stderr */
    *stdout = *stderr;
[...]

st80rules
Posts: 190
Joined: Tue, 2007-05-08, 17:45

#18 Post by st80rules »

Ah yes, there it is.

There is always a reason for everything...

Thanks for your (as always) great help.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest