This is an automated email from the ASF dual-hosted git repository. swebb2066 pushed a commit to branch next_abi_writer in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit ee807474a076e1af6dc9b7ffaa3b8ab1d24e0829 Author: Stephen Webb <[email protected]> AuthorDate: Wed May 6 17:15:45 2026 +1000 Simplify the helpers::Writer interface in a future ABI version --- src/main/cpp/bufferedwriter.cpp | 16 ++++----- src/main/cpp/bytearrayoutputstream.cpp | 6 ++-- src/main/cpp/fileoutputstream.cpp | 6 ++-- src/main/cpp/loglog.cpp | 4 +-- src/main/cpp/outputstream.cpp | 23 +++++++++++++ src/main/cpp/outputstreamwriter.cpp | 16 ++++----- src/main/cpp/rollingfileappender.cpp | 12 +++---- src/main/cpp/socketoutputstream.cpp | 8 ++--- src/main/cpp/systemerrwriter.cpp | 22 +++++++++--- src/main/cpp/systemoutwriter.cpp | 22 +++++++++--- src/main/cpp/writer.cpp | 23 +++++++++++++ src/main/include/log4cxx/helpers/bufferedwriter.h | 9 +++-- .../log4cxx/helpers/bytearrayoutputstream.h | 9 +++-- .../include/log4cxx/helpers/fileoutputstream.h | 9 +++-- src/main/include/log4cxx/helpers/outputstream.h | 39 +++++++++++++++++++++ .../include/log4cxx/helpers/outputstreamwriter.h | 9 +++-- .../include/log4cxx/helpers/socketoutputstream.h | 9 +++-- src/main/include/log4cxx/helpers/systemerrwriter.h | 12 ++++--- src/main/include/log4cxx/helpers/systemoutwriter.h | 11 ++++-- src/main/include/log4cxx/helpers/writer.h | 40 +++++++++++++++++++++- src/test/cpp/util/compare.cpp | 2 +- 21 files changed, 239 insertions(+), 68 deletions(-) diff --git a/src/main/cpp/bufferedwriter.cpp b/src/main/cpp/bufferedwriter.cpp index 0b9f70cb..db4d3e6c 100644 --- a/src/main/cpp/bufferedwriter.cpp +++ b/src/main/cpp/bufferedwriter.cpp @@ -49,32 +49,32 @@ BufferedWriter::~BufferedWriter() { } -void BufferedWriter::close(Pool& p) +void BufferedWriter::close( LOG4CXX_CLOSE_WRITER_FORMAL_PARAMETERS ) { - flush(p); - m_priv->out->close(p); + flush(); + m_priv->out->close(); } -void BufferedWriter::flush(Pool& p) +void BufferedWriter::flush( LOG4CXX_FLUSH_WRITER_FORMAL_PARAMETERS ) { if (m_priv->buf.length() > 0) { - m_priv->out->write(m_priv->buf, p); + m_priv->out->write(m_priv->buf); m_priv->buf.erase(m_priv->buf.begin(), m_priv->buf.end()); } } -void BufferedWriter::write(const LogString& str, Pool& p) +void BufferedWriter::write( LOG4CXX_WRITE_WRITER_FORMAL_PARAMETERS ) { if (m_priv->buf.length() + str.length() > m_priv->sz) { - m_priv->out->write(m_priv->buf, p); + m_priv->out->write(m_priv->buf); m_priv->buf.erase(m_priv->buf.begin(), m_priv->buf.end()); } if (str.length() > m_priv->sz) { - m_priv->out->write(str, p); + m_priv->out->write(str); } else { diff --git a/src/main/cpp/bytearrayoutputstream.cpp b/src/main/cpp/bytearrayoutputstream.cpp index 2eeab346..f98f09ae 100644 --- a/src/main/cpp/bytearrayoutputstream.cpp +++ b/src/main/cpp/bytearrayoutputstream.cpp @@ -39,15 +39,15 @@ ByteArrayOutputStream::~ByteArrayOutputStream() { } -void ByteArrayOutputStream::close(Pool& /* p */) +void ByteArrayOutputStream::close( LOG4CXX_CLOSE_OUTPUT_STREAM_FORMAL_PARAMETERS ) { } -void ByteArrayOutputStream::flush(Pool& /* p */) +void ByteArrayOutputStream::flush( LOG4CXX_FLUSH_OUTPUT_STREAM_FORMAL_PARAMETERS ) { } -void ByteArrayOutputStream::write(ByteBuffer& buf, Pool& /* p */ ) +void ByteArrayOutputStream::write( LOG4CXX_WRITE_OUTPUT_STREAM_FORMAL_PARAMETERS ) { const size_t count = buf.remaining(); const size_t sz = m_priv->array.size(); diff --git a/src/main/cpp/fileoutputstream.cpp b/src/main/cpp/fileoutputstream.cpp index 638e152b..ef6adf12 100644 --- a/src/main/cpp/fileoutputstream.cpp +++ b/src/main/cpp/fileoutputstream.cpp @@ -81,7 +81,7 @@ FileOutputStream::~FileOutputStream() } } -void FileOutputStream::close(Pool& /* p */) +void FileOutputStream::close( LOG4CXX_CLOSE_OUTPUT_STREAM_FORMAL_PARAMETERS ) { if (m_priv->fileptr) { @@ -96,11 +96,11 @@ void FileOutputStream::close(Pool& /* p */) } } -void FileOutputStream::flush(Pool& /* p */) +void FileOutputStream::flush( LOG4CXX_FLUSH_OUTPUT_STREAM_FORMAL_PARAMETERS ) { } -void FileOutputStream::write(ByteBuffer& buf, Pool& /* p */ ) +void FileOutputStream::write( LOG4CXX_WRITE_OUTPUT_STREAM_FORMAL_PARAMETERS ) { if (m_priv->fileptr == NULL) { diff --git a/src/main/cpp/loglog.cpp b/src/main/cpp/loglog.cpp index 678939b0..df5b7e71 100644 --- a/src/main/cpp/loglog.cpp +++ b/src/main/cpp/loglog.cpp @@ -206,7 +206,7 @@ void LogLog::emit_log(const LogString& prefix, const LogString& msg, const LogSt out.append(suffix); out.append(1, (logchar) 0x0A); - SystemErrWriter::write(out); + SystemErrWriter().write(out); } void LogLog::emit_log(const LogString& prefix, const std::exception& ex, const LogString& suffix) @@ -227,5 +227,5 @@ void LogLog::emit_log(const LogString& prefix, const std::exception& ex, const L out.append(suffix); out.append(1, (logchar) 0x0A); - SystemErrWriter::write(out); + SystemErrWriter().write(out); } diff --git a/src/main/cpp/outputstream.cpp b/src/main/cpp/outputstream.cpp index a02c7754..d88d04e4 100644 --- a/src/main/cpp/outputstream.cpp +++ b/src/main/cpp/outputstream.cpp @@ -17,6 +17,7 @@ #include <log4cxx/logstring.h> #include <log4cxx/helpers/outputstream.h> +#include <log4cxx/helpers/pool.h> #include <stdexcept> using namespace LOG4CXX_NS; @@ -31,3 +32,25 @@ OutputStream::OutputStream() OutputStream::~OutputStream() { } + +#if LOG4CXX_ABI_VERSION <= 15 +void OutputStream::close() +{ + Pool p; + close(p); +} +void OutputStream::flush() +{ + Pool p; + flush(p); +} +void OutputStream::write(ByteBuffer& buf) +{ + Pool p; + write(buf, p); +} +#else +void OutputStream::close(Pool&) { close(); } +void OutputStream::flush(Pool&) { flush(); } +void OutputStream::write(ByteBuffer& buf, Pool&) { write(buf); } +#endif diff --git a/src/main/cpp/outputstreamwriter.cpp b/src/main/cpp/outputstreamwriter.cpp index ba39f8f1..fbbbd222 100644 --- a/src/main/cpp/outputstreamwriter.cpp +++ b/src/main/cpp/outputstreamwriter.cpp @@ -71,24 +71,24 @@ OutputStreamWriter::~OutputStreamWriter() { } -void OutputStreamWriter::close(Pool& p) +void OutputStreamWriter::close( LOG4CXX_CLOSE_WRITER_FORMAL_PARAMETERS ) { - m_priv->out->close(p); + m_priv->out->close(); } -void OutputStreamWriter::flush(Pool& p) +void OutputStreamWriter::flush( LOG4CXX_FLUSH_WRITER_FORMAL_PARAMETERS ) { - m_priv->out->flush(p); + m_priv->out->flush(); } -void OutputStreamWriter::write(const LogString& str, Pool& p) +void OutputStreamWriter::write( LOG4CXX_WRITE_WRITER_FORMAL_PARAMETERS ) { if (str.empty()) return; if (CharsetEncoder::isTriviallyCopyable(str, m_priv->enc)) { ByteBuffer buf((char*)str.data(), str.size() * sizeof (logchar)); - m_priv->out->write(buf, p); + m_priv->out->write(buf); } else { @@ -113,14 +113,14 @@ void OutputStreamWriter::write(const LogString& str, Pool& p) { CharsetEncoder::encode(m_priv->enc, str, iter, buf); buf.flip(); - m_priv->out->write(buf, p); + m_priv->out->write(buf); buf.clear(); } CharsetEncoder::encode(m_priv->enc, str, iter, buf); m_priv->enc->flush(buf); buf.flip(); - m_priv->out->write(buf, p); + m_priv->out->write(buf); } } diff --git a/src/main/cpp/rollingfileappender.cpp b/src/main/cpp/rollingfileappender.cpp index e5d8ef04..a607037f 100644 --- a/src/main/cpp/rollingfileappender.cpp +++ b/src/main/cpp/rollingfileappender.cpp @@ -554,26 +554,26 @@ class CountingOutputStream : public OutputStream /** * {@inheritDoc} */ - void close(Pool& p) override + void close( LOG4CXX_CLOSE_OUTPUT_STREAM_FORMAL_PARAMETERS ) override { - os->close(p); + os->close(); rfa = 0; } /** * {@inheritDoc} */ - void flush(Pool& p) override + void flush( LOG4CXX_FLUSH_OUTPUT_STREAM_FORMAL_PARAMETERS ) override { - os->flush(p); + os->flush(); } /** * {@inheritDoc} */ - void write(ByteBuffer& buf, Pool& p) override + void write( LOG4CXX_WRITE_OUTPUT_STREAM_FORMAL_PARAMETERS ) override { - os->write(buf, p); + os->write(buf); if (rfa != 0) { diff --git a/src/main/cpp/socketoutputstream.cpp b/src/main/cpp/socketoutputstream.cpp index 6f2fffe9..bf4db8f6 100644 --- a/src/main/cpp/socketoutputstream.cpp +++ b/src/main/cpp/socketoutputstream.cpp @@ -45,13 +45,13 @@ SocketOutputStream::~SocketOutputStream() { } -void SocketOutputStream::close(Pool& p) +void SocketOutputStream::close( LOG4CXX_CLOSE_OUTPUT_STREAM_FORMAL_PARAMETERS ) { - flush(p); + flush(); m_priv->socket->close(); } -void SocketOutputStream::flush(Pool& /* p */) +void SocketOutputStream::flush( LOG4CXX_FLUSH_OUTPUT_STREAM_FORMAL_PARAMETERS ) { if (m_priv->array.size() > 0) { @@ -61,7 +61,7 @@ void SocketOutputStream::flush(Pool& /* p */) } } -void SocketOutputStream::write(ByteBuffer& buf, Pool& /* p */ ) +void SocketOutputStream::write( LOG4CXX_WRITE_OUTPUT_STREAM_FORMAL_PARAMETERS ) { if (buf.remaining() > 0) { diff --git a/src/main/cpp/systemerrwriter.cpp b/src/main/cpp/systemerrwriter.cpp index 97f0d108..869c38d5 100644 --- a/src/main/cpp/systemerrwriter.cpp +++ b/src/main/cpp/systemerrwriter.cpp @@ -37,18 +37,28 @@ SystemErrWriter::~SystemErrWriter() { } -void SystemErrWriter::close(Pool& /* p */) +void SystemErrWriter::close( LOG4CXX_CLOSE_WRITER_FORMAL_PARAMETERS ) { } -void SystemErrWriter::flush(Pool& /* p */) +void SystemErrWriter::flush( LOG4CXX_FLUSH_WRITER_FORMAL_PARAMETERS ) { - flush(); + fflush(stderr); } -void SystemErrWriter::write(const LogString& str, Pool& /* p */) +void SystemErrWriter::write( LOG4CXX_WRITE_WRITER_FORMAL_PARAMETERS ) { - write(str); +#if LOG4CXX_WCHAR_T_API + if (isWide()) + { + LOG4CXX_ENCODE_WCHAR(msg, str); + fputws(msg.c_str(), stderr); + return; + } + +#endif + LOG4CXX_ENCODE_CHAR(msg, str); + fputs(msg.c_str(), stderr); } bool SystemErrWriter::isWide() @@ -62,6 +72,7 @@ bool SystemErrWriter::isWide() #endif } +#if LOG4CXX_ABI_VERSION <= 15 void SystemErrWriter::write(const LogString& str) { #if LOG4CXX_WCHAR_T_API @@ -82,3 +93,4 @@ void SystemErrWriter::flush() { fflush(stderr); } +#endif \ No newline at end of file diff --git a/src/main/cpp/systemoutwriter.cpp b/src/main/cpp/systemoutwriter.cpp index d4b40b58..343ea649 100644 --- a/src/main/cpp/systemoutwriter.cpp +++ b/src/main/cpp/systemoutwriter.cpp @@ -37,18 +37,28 @@ SystemOutWriter::~SystemOutWriter() { } -void SystemOutWriter::close(Pool& /* p */ ) +void SystemOutWriter::close( LOG4CXX_CLOSE_WRITER_FORMAL_PARAMETERS ) { } -void SystemOutWriter::flush(Pool& /* p */ ) +void SystemOutWriter::flush( LOG4CXX_FLUSH_WRITER_FORMAL_PARAMETERS ) { - flush(); + fflush(stdout); } -void SystemOutWriter::write(const LogString& str, Pool& /* p */ ) +void SystemOutWriter::write( LOG4CXX_WRITE_WRITER_FORMAL_PARAMETERS ) { - write(str); +#if LOG4CXX_WCHAR_T_API + if (isWide()) + { + LOG4CXX_ENCODE_WCHAR(msg, str); + fputws(msg.c_str(), stdout); + return; + } + +#endif + LOG4CXX_ENCODE_CHAR(msg, str); + fputs(msg.c_str(), stdout); } bool SystemOutWriter::isWide() @@ -62,6 +72,7 @@ bool SystemOutWriter::isWide() #endif } +#if LOG4CXX_ABI_VERSION <= 15 void SystemOutWriter::write(const LogString& str) { #if LOG4CXX_WCHAR_T_API @@ -82,3 +93,4 @@ void SystemOutWriter::flush() { fflush(stdout); } +#endif \ No newline at end of file diff --git a/src/main/cpp/writer.cpp b/src/main/cpp/writer.cpp index 4ed3beb0..2a46ebef 100644 --- a/src/main/cpp/writer.cpp +++ b/src/main/cpp/writer.cpp @@ -18,6 +18,7 @@ #include <log4cxx/logstring.h> #include <log4cxx/helpers/writer.h> #include <log4cxx/helpers/loglog.h> +#include <log4cxx/helpers/pool.h> #include <stdexcept> using namespace LOG4CXX_NS::helpers; @@ -31,3 +32,25 @@ Writer::Writer() Writer::~Writer() { } + +#if LOG4CXX_ABI_VERSION <= 15 +void Writer::close() +{ + Pool p; + close(p); +} +void Writer::flush() +{ + Pool p; + flush(p); +} +void Writer::write(const LogString& str) +{ + Pool p; + write(str, p); +} +#else +void Writer::close(Pool&) { close(); } +void Writer::flush(Pool&) { flush(); } +void Writer::write(const LogString& str, Pool&) { write(str); } +#endif diff --git a/src/main/include/log4cxx/helpers/bufferedwriter.h b/src/main/include/log4cxx/helpers/bufferedwriter.h index 36ae80e3..fa3be51e 100644 --- a/src/main/include/log4cxx/helpers/bufferedwriter.h +++ b/src/main/include/log4cxx/helpers/bufferedwriter.h @@ -46,9 +46,12 @@ class LOG4CXX_EXPORT BufferedWriter : public Writer BufferedWriter(WriterPtr& out, size_t sz); virtual ~BufferedWriter(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(const LogString& str, Pool& p) override; + using Writer::close; + void close( LOG4CXX_CLOSE_WRITER_FORMAL_PARAMETERS ) override; + using Writer::flush; + void flush( LOG4CXX_FLUSH_WRITER_FORMAL_PARAMETERS ) override; + using Writer::write; + void write( LOG4CXX_WRITE_WRITER_FORMAL_PARAMETERS ) override; WriterPtr getWriter() const; private: diff --git a/src/main/include/log4cxx/helpers/bytearrayoutputstream.h b/src/main/include/log4cxx/helpers/bytearrayoutputstream.h index 0335914d..6f81b172 100644 --- a/src/main/include/log4cxx/helpers/bytearrayoutputstream.h +++ b/src/main/include/log4cxx/helpers/bytearrayoutputstream.h @@ -48,9 +48,12 @@ class LOG4CXX_EXPORT ByteArrayOutputStream : public OutputStream ByteArrayOutputStream(); virtual ~ByteArrayOutputStream(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(ByteBuffer& buf, Pool& p) override; + using OutputStream::close; + void close( LOG4CXX_CLOSE_OUTPUT_STREAM_FORMAL_PARAMETERS ) override; + using OutputStream::flush; + void flush( LOG4CXX_FLUSH_OUTPUT_STREAM_FORMAL_PARAMETERS ) override; + using OutputStream::write; + void write( LOG4CXX_WRITE_OUTPUT_STREAM_FORMAL_PARAMETERS ) override; ByteList toByteArray() const; private: diff --git a/src/main/include/log4cxx/helpers/fileoutputstream.h b/src/main/include/log4cxx/helpers/fileoutputstream.h index e3d6caa9..d37265c7 100644 --- a/src/main/include/log4cxx/helpers/fileoutputstream.h +++ b/src/main/include/log4cxx/helpers/fileoutputstream.h @@ -47,9 +47,12 @@ class LOG4CXX_EXPORT FileOutputStream : public OutputStream FileOutputStream(const logchar* filename, bool append = false); virtual ~FileOutputStream(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(ByteBuffer& buf, Pool& p) override; + using OutputStream::close; + void close( LOG4CXX_CLOSE_OUTPUT_STREAM_FORMAL_PARAMETERS ) override; + using OutputStream::flush; + void flush( LOG4CXX_FLUSH_OUTPUT_STREAM_FORMAL_PARAMETERS ) override; + using OutputStream::write; + void write( LOG4CXX_WRITE_OUTPUT_STREAM_FORMAL_PARAMETERS ) override; apr_file_t* getFilePtr() const; diff --git a/src/main/include/log4cxx/helpers/outputstream.h b/src/main/include/log4cxx/helpers/outputstream.h index 95d20bf5..8bb8f8ac 100644 --- a/src/main/include/log4cxx/helpers/outputstream.h +++ b/src/main/include/log4cxx/helpers/outputstream.h @@ -43,9 +43,48 @@ class LOG4CXX_EXPORT OutputStream : public Object virtual ~OutputStream(); public: +#if LOG4CXX_ABI_VERSION <= 15 + void close(); + void flush(); + void write(ByteBuffer& buf); + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + Implement this method for now, but plan to migrate to close() without a helpers::Pool parameter. + */ virtual void close(Pool& p) = 0; +#define LOG4CXX_CLOSE_OUTPUT_STREAM_FORMAL_PARAMETERS helpers::Pool& p + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + Implement this method for now, but plan to migrate to flush() without a helpers::Pool parameter. + */ virtual void flush(Pool& p) = 0; +#define LOG4CXX_FLUSH_OUTPUT_STREAM_FORMAL_PARAMETERS helpers::Pool& p + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + Implement this method for now, but plan to migrate to write() without a helpers::Pool parameter. + */ virtual void write(ByteBuffer& buf, Pool& p) = 0; +#define LOG4CXX_WRITE_OUTPUT_STREAM_FORMAL_PARAMETERS ByteBuffer& buf, helpers::Pool& p +#else + virtual void close() = 0; +#define LOG4CXX_CLOSE_OUTPUT_STREAM_FORMAL_PARAMETERS + virtual void flush() = 0; +#define LOG4CXX_FLUSH_OUTPUT_STREAM_FORMAL_PARAMETERS + virtual void write(ByteBuffer& buf) = 0; +#define LOG4CXX_WRITE_OUTPUT_STREAM_FORMAL_PARAMETERS ByteBuffer& buf + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + */ + void close(Pool& p); + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + */ + void flush(Pool& p); + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + */ + void write(ByteBuffer& buf, Pool& p); +#endif private: OutputStream(const OutputStream&); diff --git a/src/main/include/log4cxx/helpers/outputstreamwriter.h b/src/main/include/log4cxx/helpers/outputstreamwriter.h index 547744b9..623bacce 100644 --- a/src/main/include/log4cxx/helpers/outputstreamwriter.h +++ b/src/main/include/log4cxx/helpers/outputstreamwriter.h @@ -53,9 +53,12 @@ class LOG4CXX_EXPORT OutputStreamWriter : public Writer OutputStreamWriter(LOG4CXX_16_CONST OutputStreamPtr& out, LOG4CXX_16_CONST CharsetEncoderPtr& enc); ~OutputStreamWriter(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(const LogString& str, Pool& p) override; + using Writer::close; + void close( LOG4CXX_CLOSE_WRITER_FORMAL_PARAMETERS ) override; + using Writer::flush; + void flush( LOG4CXX_FLUSH_WRITER_FORMAL_PARAMETERS ) override; + using Writer::write; + void write( LOG4CXX_WRITE_WRITER_FORMAL_PARAMETERS ) override; LogString getEncoding() const; OutputStreamPtr getOutputStreamPtr() const; diff --git a/src/main/include/log4cxx/helpers/socketoutputstream.h b/src/main/include/log4cxx/helpers/socketoutputstream.h index db099b5f..1dbc3452 100644 --- a/src/main/include/log4cxx/helpers/socketoutputstream.h +++ b/src/main/include/log4cxx/helpers/socketoutputstream.h @@ -40,9 +40,12 @@ class LOG4CXX_EXPORT SocketOutputStream : public OutputStream SocketOutputStream(const SocketPtr& socket); ~SocketOutputStream(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(ByteBuffer& buf, Pool& p) override; + using OutputStream::close; + void close( LOG4CXX_CLOSE_OUTPUT_STREAM_FORMAL_PARAMETERS ) override; + using OutputStream::flush; + void flush( LOG4CXX_FLUSH_OUTPUT_STREAM_FORMAL_PARAMETERS ) override; + using OutputStream::write; + void write( LOG4CXX_WRITE_OUTPUT_STREAM_FORMAL_PARAMETERS ) override; private: LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(SocketOutputStreamPrivate, m_priv) diff --git a/src/main/include/log4cxx/helpers/systemerrwriter.h b/src/main/include/log4cxx/helpers/systemerrwriter.h index 076291db..33c702a9 100644 --- a/src/main/include/log4cxx/helpers/systemerrwriter.h +++ b/src/main/include/log4cxx/helpers/systemerrwriter.h @@ -40,13 +40,17 @@ class LOG4CXX_EXPORT SystemErrWriter : public Writer SystemErrWriter(); virtual ~SystemErrWriter(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(const LogString& str, Pool& p) override; + using Writer::close; + void close( LOG4CXX_CLOSE_WRITER_FORMAL_PARAMETERS ) override; + using Writer::flush; + void flush( LOG4CXX_FLUSH_WRITER_FORMAL_PARAMETERS ) override; + using Writer::write; + void write( LOG4CXX_WRITE_WRITER_FORMAL_PARAMETERS ) override; +#if LOG4CXX_ABI_VERSION <= 15 static void write(const LogString& str); static void flush(); - +#endif private: SystemErrWriter(const SystemErrWriter&); SystemErrWriter& operator=(const SystemErrWriter&); diff --git a/src/main/include/log4cxx/helpers/systemoutwriter.h b/src/main/include/log4cxx/helpers/systemoutwriter.h index 039a1616..00b81375 100644 --- a/src/main/include/log4cxx/helpers/systemoutwriter.h +++ b/src/main/include/log4cxx/helpers/systemoutwriter.h @@ -40,12 +40,17 @@ class LOG4CXX_EXPORT SystemOutWriter : public Writer SystemOutWriter(); ~SystemOutWriter(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(const LogString& str, Pool& p) override; + using Writer::close; + void close( LOG4CXX_CLOSE_WRITER_FORMAL_PARAMETERS ) override; + using Writer::flush; + void flush( LOG4CXX_FLUSH_WRITER_FORMAL_PARAMETERS ) override; + using Writer::write; + void write( LOG4CXX_WRITE_WRITER_FORMAL_PARAMETERS ) override; +#if LOG4CXX_ABI_VERSION <= 15 static void write(const LogString& str); static void flush(); +#endif private: SystemOutWriter(const SystemOutWriter&); SystemOutWriter& operator=(const SystemOutWriter&); diff --git a/src/main/include/log4cxx/helpers/writer.h b/src/main/include/log4cxx/helpers/writer.h index a4529316..2f006632 100644 --- a/src/main/include/log4cxx/helpers/writer.h +++ b/src/main/include/log4cxx/helpers/writer.h @@ -43,10 +43,48 @@ class LOG4CXX_EXPORT Writer : public Object virtual ~Writer(); public: +#if LOG4CXX_ABI_VERSION <= 15 + void close(); + void flush(); + void write(const LogString& str); + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + Implement this method for now, but plan to migrate to close() without a helpers::Pool parameter. + */ virtual void close(Pool& p) = 0; +#define LOG4CXX_CLOSE_WRITER_FORMAL_PARAMETERS helpers::Pool& p + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + Implement this method for now, but plan to migrate to flush() without a helpers::Pool parameter. + */ virtual void flush(Pool& p) = 0; +#define LOG4CXX_FLUSH_WRITER_FORMAL_PARAMETERS helpers::Pool& p + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + Implement this method for now, but plan to migrate to write() without a helpers::Pool parameter. + */ virtual void write(const LogString& str, Pool& p) = 0; - +#define LOG4CXX_WRITE_WRITER_FORMAL_PARAMETERS const LogString& str, helpers::Pool& p +#else + virtual void close() = 0; +#define LOG4CXX_CLOSE_WRITER_FORMAL_PARAMETERS + virtual void flush() = 0; +#define LOG4CXX_FLUSH_WRITER_FORMAL_PARAMETERS + virtual void write(const LogString& str) = 0; +#define LOG4CXX_WRITE_WRITER_FORMAL_PARAMETERS const LogString& str + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + */ + void close(Pool& p); + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + */ + void flush(Pool& p); + /** + @deprecated The \c pool parameter is not used and will be removed in a future version. + */ + void write(const LogString& str, Pool& p); +#endif private: Writer(const Writer&); Writer& operator=(const Writer&); diff --git a/src/test/cpp/util/compare.cpp b/src/test/cpp/util/compare.cpp index eedb9902..4a71b818 100644 --- a/src/test/cpp/util/compare.cpp +++ b/src/test/cpp/util/compare.cpp @@ -145,7 +145,7 @@ void Compare::outputFile(const File& file, void Compare::emit(const LogString& s1) { - SystemOutWriter::write(s1); + SystemOutWriter().write(s1); }
