.\" ident @(#)wclog.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH wclog 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2wclog\fP \ - Controls output to a stream buffer associated with the object \f2stderr\fP declared in \f2\fP. .SH SYNOPSIS .br #include .br extern wostream wclog; .br wostream wclog; .SH DESCRIPTION The object \f2wclog\fP controls output to a stream buffer associated with the object \f2stderr\fP declared in \f2\fP. The difference between \f2wclog\fP and \f2wcerr\fP is that \f2wclog\fP is buffered, but \f2wcerr\fP isn't. Therefore, commands like \f2wclog << L"ERROR !!";\fP and \f2fprintf(stderr,"ERROR !!");\fP are not synchronized. \f2wclog\fP uses the locale \f2codecvt\fP facet to convert the wide characters it receives to the tiny characters it outputs to \f2stderr\fP. .SH FORMATTING The formatting is done through member functions or manipulators. See cout, wcout or basic_ostream for details. .SH EXAMPLE .br // .br // wclog example .br // .br #include .br #include .br .br void main ( ) .br { .RE .RS 1 using namespace std; .RE .RS 0 .RE .RS 2 // open the file "file_name.txt" .br // for reading .RE .RS 1 wifstream in("file_name.txt"); .RE .RS 2 .br // output the all file to stdout .RE .RS 1 if ( in ) .RE .RS 3 wcout << in.rdbuf(); .RE .RS 1 else .RE .RS 4 // if the wifstream object is in a bad state .br // output an error message to stderr .RE .RS 3 wclog << L"Error while opening the file" << endl; .RE .RS 0 } .SH WARNINGS \f2wclog\fP can be used to redirect some of the errors to another recipient. For example, you might want to redirect them to a file named \f2my_err\fP: .br wofstream out("my_err"); .br if ( out ) .RE .RS 1 wclog.rdbuf(out.rdbuf()); .RE .RS 0 else .RE .RS 1 cerr << "Error while opening the file" << endl; Then when you are doing something like \f2wclog << L"error number x";\fP the error message is output to the file \f2my_err\fP. You can use the same scheme to redirect \f2wclog\fP to other devices. If your compiler does not support namespaces, then you do not need the using declaration for \f2std\fP. .SH SEE ALSO basic_ostream(3C++), basic_iostream(3C++), basic_filebuf(3C++), cout(3C++), cin(3C++), cerr(3C++), clog(3C++), wcin(3C++), wcout(3C++), wcerr(3C++), iomanip(3C++), ios_base(3C++), basic_ios(3C++) Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Section 27.3.2 .SH STANDARDS CONFORMANCE ANSI X3J16/ISO WG21 Joint C++ Committee