/src/logging-log4cxx/src/main/cpp/systemerrwriter.cpp
| Line | Count | Source | 
| 1 |  | /* | 
| 2 |  |  * Licensed to the Apache Software Foundation (ASF) under one or more | 
| 3 |  |  * contributor license agreements.  See the NOTICE file distributed with | 
| 4 |  |  * this work for additional information regarding copyright ownership. | 
| 5 |  |  * The ASF licenses this file to You under the Apache License, Version 2.0 | 
| 6 |  |  * (the "License"); you may not use this file except in compliance with | 
| 7 |  |  * the License.  You may obtain a copy of the License at | 
| 8 |  |  * | 
| 9 |  |  *      http://www.apache.org/licenses/LICENSE-2.0 | 
| 10 |  |  * | 
| 11 |  |  * Unless required by applicable law or agreed to in writing, software | 
| 12 |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
| 13 |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| 14 |  |  * See the License for the specific language governing permissions and | 
| 15 |  |  * limitations under the License. | 
| 16 |  |  */ | 
| 17 |  |  | 
| 18 |  | #include <log4cxx/logstring.h> | 
| 19 |  | #include <log4cxx/helpers/systemerrwriter.h> | 
| 20 |  | #include <log4cxx/helpers/transcoder.h> | 
| 21 |  | #include <stdio.h> | 
| 22 |  | #if !defined(LOG4CXX) | 
| 23 |  |   #define LOG4CXX 1 | 
| 24 |  | #endif | 
| 25 |  | #include <log4cxx/private/log4cxx_private.h> | 
| 26 |  |  | 
| 27 |  | using namespace LOG4CXX_NS; | 
| 28 |  | using namespace LOG4CXX_NS::helpers; | 
| 29 |  |  | 
| 30 |  | IMPLEMENT_LOG4CXX_OBJECT(SystemErrWriter) | 
| 31 |  |  | 
| 32 |  | SystemErrWriter::SystemErrWriter() | 
| 33 | 0 | { | 
| 34 | 0 | } | 
| 35 |  |  | 
| 36 |  | SystemErrWriter::~SystemErrWriter() | 
| 37 | 0 | { | 
| 38 | 0 | } | 
| 39 |  |  | 
| 40 |  | void SystemErrWriter::close(Pool& /* p */) | 
| 41 | 0 | { | 
| 42 | 0 | } | 
| 43 |  |  | 
| 44 |  | void SystemErrWriter::flush(Pool& /* p */) | 
| 45 | 0 | { | 
| 46 | 0 |   flush(); | 
| 47 | 0 | } | 
| 48 |  |  | 
| 49 |  | void SystemErrWriter::write(const LogString& str, Pool& /* p */) | 
| 50 | 0 | { | 
| 51 | 0 |   write(str); | 
| 52 | 0 | } | 
| 53 |  |  | 
| 54 |  | bool SystemErrWriter::isWide() | 
| 55 | 0 | { | 
| 56 |  | #if LOG4CXX_FORCE_WIDE_CONSOLE | 
| 57 |  |   return true; | 
| 58 |  | #elif LOG4CXX_FORCE_BYTE_CONSOLE || !LOG4CXX_HAS_FWIDE | 
| 59 |  |   return false; | 
| 60 |  | #else | 
| 61 | 0 |   return fwide(stderr, 0) > 0; | 
| 62 | 0 | #endif | 
| 63 | 0 | } | 
| 64 |  |  | 
| 65 |  | void SystemErrWriter::write(const LogString& str) | 
| 66 | 0 | { | 
| 67 | 0 | #if LOG4CXX_WCHAR_T_API | 
| 68 |  | 
 | 
| 69 | 0 |   if (isWide()) | 
| 70 | 0 |   { | 
| 71 | 0 |     LOG4CXX_ENCODE_WCHAR(msg, str); | 
| 72 | 0 |     fputws(msg.c_str(), stderr); | 
| 73 | 0 |     return; | 
| 74 | 0 |   } | 
| 75 |  |  | 
| 76 | 0 | #endif | 
| 77 | 0 |   LOG4CXX_ENCODE_CHAR(msg, str); | 
| 78 | 0 |   fputs(msg.c_str(), stderr); | 
| 79 | 0 | } | 
| 80 |  |  | 
| 81 |  | void SystemErrWriter::flush() | 
| 82 | 0 | { | 
| 83 |  |   fflush(stderr); | 
| 84 | 0 | } |