You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ca...@apache.org on 2008/02/15 07:54:43 UTC
svn commit: r627964 - in /logging/log4cxx/trunk/src: main/cpp/
main/include/log4cxx/ test/cpp/ test/cpp/util/
Author: carnold
Date: Thu Feb 14 22:54:41 2008
New Revision: 627964
URL: http://svn.apache.org/viewvc?rev=627964&view=rev
Log:
LOGCXX-241: Replace File::getName/setName with getPath/setPath
Modified:
logging/log4cxx/trunk/src/main/cpp/defaultconfigurator.cpp
logging/log4cxx/trunk/src/main/cpp/domconfigurator.cpp
logging/log4cxx/trunk/src/main/cpp/file.cpp
logging/log4cxx/trunk/src/main/cpp/fileappender.cpp
logging/log4cxx/trunk/src/main/cpp/fileinputstream.cpp
logging/log4cxx/trunk/src/main/cpp/filewatchdog.cpp
logging/log4cxx/trunk/src/main/cpp/fixedwindowrollingpolicy.cpp
logging/log4cxx/trunk/src/main/cpp/optionconverter.cpp
logging/log4cxx/trunk/src/main/cpp/propertyconfigurator.cpp
logging/log4cxx/trunk/src/main/cpp/rollingfileappender.cpp
logging/log4cxx/trunk/src/main/cpp/timebasedrollingpolicy.cpp
logging/log4cxx/trunk/src/main/include/log4cxx/file.h
logging/log4cxx/trunk/src/test/cpp/fileappendertestcase.cpp
logging/log4cxx/trunk/src/test/cpp/filetestcase.cpp
logging/log4cxx/trunk/src/test/cpp/util/compare.cpp
Modified: logging/log4cxx/trunk/src/main/cpp/defaultconfigurator.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/defaultconfigurator.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/defaultconfigurator.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/defaultconfigurator.cpp Thu Feb 14 22:54:41 2008
@@ -33,29 +33,26 @@
const LogString configuratorClassName(getConfiguratorClass());
LogString configurationOptionStr(getConfigurationFileName());
- File configuration;
-
Pool pool;
+ File configuration;
if (configurationOptionStr.empty())
{
- configuration.setName(LOG4CXX_STR("log4cxx.xml"));
- if (!configuration.exists(pool)) {
- configuration.setName(LOG4CXX_STR("log4cxx.properties"));
- if (!configuration.exists(pool)) {
- configuration.setName(LOG4CXX_STR("log4j.xml"));
- if (!configuration.exists(pool)) {
- configuration.setName(LOG4CXX_STR("log4j.properties"));
- }
- }
+ const char* names[] = { "log4cxx.xml", "log4cxx.properties", "log4j.xml", "log4j.properties", 0 };
+ for (int i = 0; names[i] != 0; i++) {
+ File candidate(names[i]);
+ if (candidate.exists(pool)) {
+ configuration = candidate;
+ break;
}
+ }
} else {
- configuration.setName(configurationOptionStr);
+ configuration.setPath(configurationOptionStr);
}
if (configuration.exists(pool))
{
LogString msg(LOG4CXX_STR("Using configuration file ["));
- msg += configuration.getName();
+ msg += configuration.getPath();
msg += LOG4CXX_STR("] for automatic log4cxx configuration");
LogLog::debug(msg);
Modified: logging/log4cxx/trunk/src/main/cpp/domconfigurator.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/domconfigurator.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/domconfigurator.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/domconfigurator.cpp Thu Feb 14 22:54:41 2008
@@ -703,7 +703,7 @@
repository1->setConfigured(true);
this->repository = repository1;
LogString msg(LOG4CXX_STR("DOMConfigurator configuring file "));
- msg.append(filename.getName());
+ msg.append(filename.getPath());
msg.append(LOG4CXX_STR("..."));
LogLog::debug(msg);
@@ -715,7 +715,7 @@
log4cxx_status_t rv = filename.open(&fd, APR_READ, APR_OS_DEFAULT, p);
if (rv != APR_SUCCESS) {
LogString msg2(LOG4CXX_STR("Could not open file ["));
- msg2.append(filename.getName());
+ msg2.append(filename.getPath());
msg2.append(LOG4CXX_STR("]."));
LogLog::error(msg2);
} else {
@@ -726,7 +726,7 @@
char errbuf[2000];
char errbufXML[2000];
LogString msg2(LOG4CXX_STR("Error parsing file ["));
- msg2.append(filename.getName());
+ msg2.append(filename.getPath());
msg2.append(LOG4CXX_STR("], "));
apr_strerror(rv, errbuf, sizeof(errbuf));
LOG4CXX_DECODE_CHAR(lerrbuf, std::string(errbuf));
Modified: logging/log4cxx/trunk/src/main/cpp/file.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/file.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/file.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/file.cpp Thu Feb 14 22:54:41 2008
@@ -101,7 +101,7 @@
}
-LogString File::getName() const {
+LogString File::getPath() const {
return name;
}
@@ -112,8 +112,8 @@
return *this;
}
-File& File::setName(const LogString& newName) {
- return setPath(newName);
+LogString File::getName() const {
+ return name;
}
std::string File::getOSName() const {
Modified: logging/log4cxx/trunk/src/main/cpp/fileappender.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/fileappender.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/fileappender.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/fileappender.cpp Thu Feb 14 22:54:41 2008
@@ -257,7 +257,7 @@
//
if (append1) {
File outFile;
- outFile.setName(filename);
+ outFile.setPath(filename);
writeBOM = !outFile.exists(p);
} else {
writeBOM = true;
@@ -268,10 +268,10 @@
try {
outStream = new FileOutputStream(filename, append1);
} catch(IOException& ex) {
- LogString parentName = File().setName(filename).getParent(p);
+ LogString parentName = File().setPath(filename).getParent(p);
if (!parentName.empty()) {
File parentDir;
- parentDir.setName(parentName);
+ parentDir.setPath(parentName);
if(!parentDir.exists(p) && parentDir.mkdirs(p)) {
outStream = new FileOutputStream(filename, append1);
} else {
Modified: logging/log4cxx/trunk/src/main/cpp/fileinputstream.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/fileinputstream.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/fileinputstream.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/fileinputstream.cpp Thu Feb 14 22:54:41 2008
@@ -44,7 +44,7 @@
void FileInputStream::open(const LogString& filename) {
apr_fileperms_t perm = APR_OS_DEFAULT;
apr_int32_t flags = APR_READ;
- apr_status_t stat = File().setName(filename).open(&fileptr, flags, perm, pool);
+ apr_status_t stat = File().setPath(filename).open(&fileptr, flags, perm, pool);
if (stat != APR_SUCCESS) {
throw IOException(stat);
}
Modified: logging/log4cxx/trunk/src/main/cpp/filewatchdog.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/filewatchdog.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/filewatchdog.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/filewatchdog.cpp Thu Feb 14 22:54:41 2008
@@ -49,7 +49,7 @@
if(!warnedAlready)
{
LogLog::debug(((LogString) LOG4CXX_STR("["))
- + file.getName()
+ + file.getPath()
+ LOG4CXX_STR("] does not exist."));
warnedAlready = true;
}
Modified: logging/log4cxx/trunk/src/main/cpp/fixedwindowrollingpolicy.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/fixedwindowrollingpolicy.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/fixedwindowrollingpolicy.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/fixedwindowrollingpolicy.cpp Thu Feb 14 22:54:41 2008
@@ -149,17 +149,17 @@
renameTo.resize(renameTo.size() - 3);
compressAction =
new GZCompressAction(
- File().setName(renameTo), File().setName(compressedName), true);
+ File().setPath(renameTo), File().setPath(compressedName), true);
} else if (StringHelper::endsWith(renameTo, LOG4CXX_STR(".zip"))) {
renameTo.resize(renameTo.size() - 4);
compressAction =
new ZipCompressAction(
- File().setName(renameTo), File().setName(compressedName), true);
+ File().setPath(renameTo), File().setPath(compressedName), true);
}
FileRenameActionPtr renameAction =
new FileRenameAction(
- File().setName(currentFileName), File().setName(renameTo), false);
+ File().setPath(currentFileName), File().setPath(renameTo), false);
desc = new RolloverDescription(
currentFileName, false, renameAction, compressAction);
@@ -210,9 +210,9 @@
for (int i = lowIndex; i <= highIndex; i++) {
File toRenameCompressed;
- toRenameCompressed.setName(lowFilename);
+ toRenameCompressed.setPath(lowFilename);
File toRenameBase;
- toRenameBase.setName(lowFilename.substr(0, lowFilename.length() - suffixLength));
+ toRenameBase.setPath(lowFilename.substr(0, lowFilename.length() - suffixLength));
File* toRename = &toRenameCompressed;
bool isBase = false;
bool exists = toRenameCompressed.exists(p);
@@ -257,7 +257,7 @@
highFilename.substr(0, highFilename.length() - suffixLength);
}
- renames.push_back(new FileRenameAction(*toRename, File().setName(renameTo), true));
+ renames.push_back(new FileRenameAction(*toRename, File().setPath(renameTo), true));
lowFilename = highFilename;
} else {
break;
Modified: logging/log4cxx/trunk/src/main/cpp/optionconverter.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/optionconverter.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/optionconverter.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/optionconverter.cpp Thu Feb 14 22:54:41 2008
@@ -349,7 +349,7 @@
ConfiguratorPtr configurator;
LogString clazz = _clazz;
- LogString filename(configFileName.getName());
+ LogString filename(configFileName.getPath());
if(clazz.empty()
&& filename.length() > 4
&& StringHelper::equalsIgnoreCase(
Modified: logging/log4cxx/trunk/src/main/cpp/propertyconfigurator.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/propertyconfigurator.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/propertyconfigurator.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/propertyconfigurator.cpp Thu Feb 14 22:54:41 2008
@@ -101,7 +101,7 @@
props.load(inputStream);
} catch(const IOException& ie) {
LogLog::error(((LogString) LOG4CXX_STR("Could not read configuration file ["))
- + configFileName.getName() + LOG4CXX_STR("]."));
+ + configFileName.getPath() + LOG4CXX_STR("]."));
return;
}
@@ -109,7 +109,7 @@
doConfigure(props, hierarchy);
} catch(const std::exception& ex) {
LogLog::error(((LogString) LOG4CXX_STR("Could not parse configuration file ["))
- + configFileName.getName() + LOG4CXX_STR("]."), ex);
+ + configFileName.getPath() + LOG4CXX_STR("]."), ex);
}
}
Modified: logging/log4cxx/trunk/src/main/cpp/rollingfileappender.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/rollingfileappender.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/rollingfileappender.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/rollingfileappender.cpp Thu Feb 14 22:54:41 2008
@@ -95,7 +95,7 @@
}
File activeFile;
- activeFile.setName(getFile());
+ activeFile.setPath(getFile());
if (getAppend()) {
fileLength = activeFile.length(p);
@@ -172,7 +172,7 @@
if (success) {
if (rollover1->getAppend()) {
- fileLength = File().setName(rollover1->getActiveFileName()).length(p);
+ fileLength = File().setPath(rollover1->getActiveFileName()).length(p);
} else {
fileLength = 0;
}
@@ -214,7 +214,7 @@
if (success) {
if (rollover1->getAppend()) {
- fileLength = File().setName(rollover1->getActiveFileName()).length(p);
+ fileLength = File().setPath(rollover1->getActiveFileName()).length(p);
} else {
fileLength = 0;
}
Modified: logging/log4cxx/trunk/src/main/cpp/timebasedrollingpolicy.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/timebasedrollingpolicy.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/timebasedrollingpolicy.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/timebasedrollingpolicy.cpp Thu Feb 14 22:54:41 2008
@@ -161,20 +161,20 @@
if (currentActiveFile != lastBaseName) {
renameAction =
new FileRenameAction(
- File().setName(currentActiveFile), File().setName(lastBaseName), true);
+ File().setPath(currentActiveFile), File().setPath(lastBaseName), true);
nextActiveFile = currentActiveFile;
}
if (suffixLength == 3) {
compressAction =
new GZCompressAction(
- File().setName(lastBaseName), File().setName(lastFileName), true);
+ File().setPath(lastBaseName), File().setPath(lastFileName), true);
}
if (suffixLength == 4) {
compressAction =
new ZipCompressAction(
- File().setName(lastBaseName), File().setName(lastFileName), true);
+ File().setPath(lastBaseName), File().setPath(lastFileName), true);
}
lastFileName = newFileName;
Modified: logging/log4cxx/trunk/src/main/include/log4cxx/file.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/file.h?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/file.h (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/file.h Thu Feb 14 22:54:41 2008
@@ -61,7 +61,7 @@
size_t length(log4cxx::helpers::Pool& p) const;
log4cxx_time_t lastModified(log4cxx::helpers::Pool& p) const;
LogString getName() const;
- File& setName(const LogString&);
+ LogString getPath() const;
File& setPath(const LogString&);
std::string getOSName() const;
Modified: logging/log4cxx/trunk/src/test/cpp/fileappendertestcase.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/fileappendertestcase.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/fileappendertestcase.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/fileappendertestcase.cpp Thu Feb 14 22:54:41 2008
@@ -59,7 +59,7 @@
FileAppender appender;
appender.setOption(LOG4CXX_STR("FILE"), LOG4CXX_STR("output\\\\temp"));
const File& file = appender.getFile();
- LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("output\\temp"), file.getName());
+ LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("output\\temp"), file.getPath());
}
/**
@@ -72,7 +72,7 @@
FileAppender appender;
appender.setOption(LOG4CXX_STR("FILE"), LOG4CXX_STR("output\\\\temp"));
const File& file = appender.getFile();
- LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("output\\temp"), file.getName());
+ LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("output\\temp"), file.getPath());
}
/**
Modified: logging/log4cxx/trunk/src/test/cpp/filetestcase.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/filetestcase.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/filetestcase.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/filetestcase.cpp Thu Feb 14 22:54:41 2008
@@ -62,7 +62,7 @@
public:
void defaultConstructor() {
File defFile;
- LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR(""), defFile.getName());
+ LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR(""), defFile.getPath());
}
Modified: logging/log4cxx/trunk/src/test/cpp/util/compare.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/util/compare.cpp?rev=627964&r1=627963&r2=627964&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/util/compare.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/util/compare.cpp Thu Feb 14 22:54:41 2008
@@ -55,9 +55,9 @@
if (s1 != s2) {
LogString msg(LOG4CXX_STR("Files ["));
- msg += file1.getName();
+ msg += file1.getPath();
msg += LOG4CXX_STR("] and [");
- msg += file2.getName();
+ msg += file2.getPath();
msg += LOG4CXX_STR("] differ on line ");
StringHelper::toString(lineCounter, pool, msg);
msg += LOG4CXX_EOL;
@@ -81,9 +81,9 @@
// the second file is longer
if (getline(in2, s2)) {
LogString msg(LOG4CXX_STR("File ["));
- msg += file2.getName();
+ msg += file2.getPath();
msg += LOG4CXX_STR("] longer than file [");
- msg += file1.getName();
+ msg += file1.getPath();
msg += LOG4CXX_STR("].");
msg += LOG4CXX_EOL;
emit(msg);
@@ -104,7 +104,7 @@
emit(LOG4CXX_STR("--------------------------------"));
emit(LOG4CXX_EOL);
LogString msg(LOG4CXX_STR("Contents of "));
- msg += file.getName();
+ msg += file.getPath();
msg += LOG4CXX_STR(":");
msg += LOG4CXX_EOL;
emit(msg);