Hello,
I made a patch that should create files (via FileOutputStream) only when a
message is actually logged to the file (see the patch below).
What was bothering us was that we had plenty of empty logging files.
My questions are:
1. Is this a good idea? And if yes would you be interested in integrating
this patch?
2. I have tests failing. How does one debug/run one test at a time? I'm
more familiar to gtest, from what I see log4cxx uses something closer to
cppunit.
Here are the failing tests (Linux 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29
11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux)
Failed Tests Total Fail Failed %
===================================================
hierarchythresholdtestcase 8 1 12.50%
manualrollingtest 4 1 25.00%
sizebasedrollingtest 6 1 16.67%
timebasedrollingtest 6 6 100.00%
Thanks in advance,
Cosmin
====
//depot/v3.1.build.dev.29464.nodryrun/thirdparty/apache-log4cxx-0.10.0/src/src/main/cpp/fileoutputstream.cpp#1
-
/src/new/v3.1.build.dev.29464.nodryrun/thirdparty/apache-log4cxx-0.10.0/src/src/main/cpp/fileoutputstream.cpp
====
***************
*** 31,43 ****
IMPLEMENT_LOG4CXX_OBJECT(FileOutputStream)
FileOutputStream::FileOutputStream(const LogString& filename,
! bool append) : pool(), fileptr(open(filename, append, pool)) {
}
FileOutputStream::FileOutputStream(const logchar* filename,
! bool append) : pool(), fileptr(open(filename, append, pool)) {
}
apr_file_t* FileOutputStream::open(const LogString& filename,
bool append, Pool& pool) {
--- 31,45 ----
IMPLEMENT_LOG4CXX_OBJECT(FileOutputStream)
FileOutputStream::FileOutputStream(const LogString& filename,
! bool append) : pool(), fileptr(NULL), logappend(append) {
! logfilename = filename;
}
FileOutputStream::FileOutputStream(const logchar* filename,
! bool append) : pool(), fileptr(NULL), logappend(append) {
! logfilename = filename;
}
apr_file_t* FileOutputStream::open(const LogString& filename,
bool append, Pool& pool) {
***************
*** 60,67 ****
--- 62,70 ----
FileOutputStream::~FileOutputStream() {
if (fileptr != NULL && !APRInitializer::isDestructed) {
apr_file_close(fileptr);
+ fileptr = NULL;
}
}
void FileOutputStream::close(Pool& /* p */) {
***************
*** 78,85 ****
--- 81,91 ----
}
void FileOutputStream::write(ByteBuffer& buf, Pool& /* p */ ) {
if (fileptr == NULL) {
+ fileptr = open(logfilename, logappend, pool);
+ }
+ if (fileptr == NULL) {
throw IOException(-1);
}
size_t nbytes = buf.remaining();
size_t pos = buf.position();
====
//depot/v3.1.build.dev.29464.nodryrun/thirdparty/apache-log4cxx-0.10.0/src/src/main/include/log4cxx/helpers/fileoutputstream.h#1
-
/src/new/v3.1.build.dev.29464.nodryrun/thirdparty/apache-log4cxx-0.10.0/src/src/main/include/log4cxx/helpers/fileoutputstream.h
====
***************
*** 35,42 ****
--- 35,44 ----
{
private:
Pool pool;
apr_file_t* fileptr;
+ LogString logfilename;
+ bool logappend;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileOutputStream)
BEGIN_LOG4CXX_CAST_MAP()
*******************************
This e-mail contains information for the intended recipient only. It may
contain proprietary material or confidential information. If you are not the
intended recipient you are not authorised to distribute, copy or use this
e-mail or any attachment to it. Murex cannot guarantee that it is virus free
and accepts no responsibility for any loss or damage arising from its use. If
you have received this e-mail in error please notify immediately the sender and
delete the original email received, any attachments and all copies from your
system.