/src/logging-log4cxx/src/main/cpp/systemerrwriter.cpp
Line | Count | Source (jump to first uncovered line) |
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 | } Unexecuted instantiation: log4cxx::helpers::SystemErrWriter::write(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, log4cxx::helpers::Pool&) Unexecuted instantiation: log4cxx::helpers::SystemErrWriter::write(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&, log4cxx::helpers::Pool&) |
53 | | |
54 | | bool SystemErrWriter::isWide() |
55 | 71.7k | { |
56 | | #if LOG4CXX_FORCE_WIDE_CONSOLE |
57 | | return true; |
58 | | #elif LOG4CXX_FORCE_BYTE_CONSOLE || !LOG4CXX_HAS_FWIDE |
59 | | return false; |
60 | | #else |
61 | 71.7k | return fwide(stderr, 0) > 0; |
62 | 71.7k | #endif |
63 | 71.7k | } |
64 | | |
65 | | void SystemErrWriter::write(const LogString& str) |
66 | 71.7k | { |
67 | 71.7k | #if LOG4CXX_WCHAR_T_API |
68 | | |
69 | 71.7k | 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 | 71.7k | #endif |
77 | 71.7k | LOG4CXX_ENCODE_CHAR(msg, str); |
78 | 71.7k | fputs(msg.c_str(), stderr); |
79 | 71.7k | } log4cxx::helpers::SystemErrWriter::write(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 66 | 33.2k | { | 67 | 33.2k | #if LOG4CXX_WCHAR_T_API | 68 | | | 69 | 33.2k | 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 | 33.2k | #endif | 77 | 33.2k | LOG4CXX_ENCODE_CHAR(msg, str); | 78 | 33.2k | fputs(msg.c_str(), stderr); | 79 | 33.2k | } |
log4cxx::helpers::SystemErrWriter::write(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) Line | Count | Source | 66 | 38.4k | { | 67 | 38.4k | #if LOG4CXX_WCHAR_T_API | 68 | | | 69 | 38.4k | 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 | 38.4k | #endif | 77 | 38.4k | LOG4CXX_ENCODE_CHAR(msg, str); | 78 | 38.4k | fputs(msg.c_str(), stderr); | 79 | 38.4k | } |
|
80 | | |
81 | | void SystemErrWriter::flush() |
82 | 0 | { |
83 | 0 | fflush(stderr); |
84 | 0 | } |