From 0bce06348e3be57c97e246d2a7af71683dc76ede Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 20 Jan 2008 15:20:16 +0000 Subject: [PATCH] 2008-01-21 Tatsuhiro Tsujikawa Fixed the bug that log file is not written when configuration file doesn't exist. This is caused by using Logger class before LogFactory is not configured. BUG #1875079 * src/option_processing.cc Warning message "configuration doesn't exist" is only printed when --conf is given. * src/option_processing.cc --- ChangeLog | 11 +++++++++++ src/option_processing.cc | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c5a2679a..c96e7fd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-01-21 Tatsuhiro Tsujikawa + + Fixed the bug that log file is not written when configuration file doesn't exist. + This is caused by using Logger class before LogFactory is not configured. + BUG #1875079 + * src/option_processing.cc + + Warning message "configuration doesn't exist" is only printed when --conf is + given. + * src/option_processing.cc + 2008-01-12 Tatsuhiro Tsujikawa Use BencodeVisitor and MessageDigestHelper instead of ShaVisitor. diff --git a/src/option_processing.cc b/src/option_processing.cc index 3b50c14f..4da41332 100644 --- a/src/option_processing.cc +++ b/src/option_processing.cc @@ -136,7 +136,8 @@ Option* option_processing(int argc, char* const argv[]) // following options are not parsed by OptionHandler and not stored in Option. bool noConf = false; - string cfname = Util::getHomeDir()+"/.aria2/aria2.conf"; + string defaultCfname = Util::getHomeDir()+"/.aria2/aria2.conf"; + string ucfname; while(1) { int optIndex = 0; @@ -365,7 +366,7 @@ Option* option_processing(int argc, char* const argv[]) noConf = true; break; case 213: - cfname = optarg; + ucfname = optarg; break; } break; @@ -455,6 +456,12 @@ Option* option_processing(int argc, char* const argv[]) OptionParser oparser; oparser.setOptionHandlers(OptionHandlerFactory::createOptionHandlers()); if(!noConf) { + string cfname; + if(ucfname.size()) { + cfname = ucfname; + } else { + cfname = defaultCfname; + } if(File(cfname).isFile()) { ifstream cfstream(cfname.c_str()); try { @@ -465,8 +472,9 @@ Option* option_processing(int argc, char* const argv[]) delete e; exit(EXIT_FAILURE); } - } else { - LogFactory::getInstance()->warn("Configuration file %s is not found.", cfname.c_str()); + } else if(ucfname.size()) { + printf("Configuration file %s is not found.", cfname.c_str()); + cout << "\n"; } } try {