From: Michael Andres Date: Thu, 23 Oct 2008 09:15:07 +0000 (+0000) Subject: enhance loging X-Git-Tag: BASE-SuSE-Code-11-Branch~220 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd297646e7361e6ebfcd993ceaef73c3779b4212;p=platform%2Fupstream%2Flibzypp.git enhance loging --- diff --git a/zypp/ZConfig.cc b/zypp/ZConfig.cc index 25fd9ab..a9e30fc 100644 --- a/zypp/ZConfig.cc +++ b/zypp/ZConfig.cc @@ -30,6 +30,9 @@ using namespace std; using namespace zypp::filesystem; using namespace zypp::parser; +#undef ZYPP_BASE_LOGGER_LOGGROUP +#define ZYPP_BASE_LOGGER_LOGGROUP "zconfig" + /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// @@ -142,7 +145,8 @@ namespace zypp { public: Impl( const Pathname & override_r = Pathname() ) - : cfg_arch ( defaultSystemArchitecture() ) + : _parsedZyppConf ( override_r ) + , cfg_arch ( defaultSystemArchitecture() ) , cfg_textLocale ( defaultTextLocale() ) , repo_add_probe ( false ) , repo_refresh_delay ( 10 ) @@ -153,27 +157,23 @@ namespace zypp { MIL << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl; - - // override_r has higest prio + // override_r has higest prio // ZYPP_CONF might override /etc/zypp/zypp.conf - Pathname confpath( override_r ); - if ( confpath.empty() ) + if ( _parsedZyppConf.empty() ) { const char *env_confpath = getenv( "ZYPP_CONF" ); - confpath = env_confpath ? env_confpath : "/etc/zypp/zypp.conf"; + _parsedZyppConf = env_confpath ? env_confpath : "/etc/zypp/zypp.conf"; } else { // Inject this into ZConfig. Be shure this is // allocated via new. See: reconfigureZConfig - INT << "Reconfigure to " << confpath << endl; + INT << "Reconfigure to " << _parsedZyppConf << endl; ZConfig::instance()._pimpl.reset( this ); } - if ( PathInfo(confpath).isExist() ) + if ( PathInfo(_parsedZyppConf).isExist() ) { - parser::IniDict dict( confpath ); - //InputStream is(confpath); - + parser::IniDict dict( _parsedZyppConf ); for ( IniDict::section_const_iterator sit = dict.sectionsBegin(); sit != dict.sectionsEnd(); ++sit ) @@ -305,7 +305,8 @@ namespace zypp } else { - MIL << confpath << " not found, using defaults instead." << endl; + MIL << _parsedZyppConf << " not found, using defaults instead." << endl; + _parsedZyppConf.extend( " (NOT FOUND)" ); } // legacy: @@ -318,16 +319,16 @@ namespace zypp cfg_arch = carch; } } - MIL << "ZConfig singleton created." << endl; - MIL << "defaultTextLocale: '" << cfg_textLocale << "'" << endl; - MIL << "System architecture is '" << cfg_arch << "'" << endl; } ~Impl() {} public: + /** Remember any parsed zypp.conf. */ + Pathname _parsedZyppConf; + Arch cfg_arch; Locale cfg_textLocale; @@ -394,7 +395,9 @@ namespace zypp // ZConfig::ZConfig() : _pimpl( new Impl ) - {} + { + about( MIL); + } /////////////////////////////////////////////////////////////////// // @@ -599,6 +602,17 @@ namespace zypp Pathname("/etc/zypp/credentials.cat") : _pimpl->credentials_global_file_path ); } + /////////////////////////////////////////////////////////////////// + + std::ostream & ZConfig::about( std::ostream & str ) const + { + str << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl; + str << "zypp.conf: '" << _pimpl->_parsedZyppConf << "'" << endl; + str << "TextLocale: '" << textLocale() << "' (" << defaultTextLocale() << ")" << endl; + str << "SystemArchitecture: '" << systemArchitecture() << "' (" << defaultSystemArchitecture() << ")" << endl; + return str; + } + ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// diff --git a/zypp/ZConfig.h b/zypp/ZConfig.h index 5e4fd02..9d82401 100644 --- a/zypp/ZConfig.h +++ b/zypp/ZConfig.h @@ -59,6 +59,9 @@ namespace zypp /** Singleton ctor */ static ZConfig & instance(); + /** Print some detail about the current libzypp version.*/ + std::ostream & about( std::ostream & str ) const; + public: /** The autodetected system architecture. */ diff --git a/zypp/zypp_detail/ZYppImpl.cc b/zypp/zypp_detail/ZYppImpl.cc index 22827b0..86559e1 100644 --- a/zypp/zypp_detail/ZYppImpl.cc +++ b/zypp/zypp_detail/ZYppImpl.cc @@ -43,9 +43,7 @@ namespace zypp : _target(0) , _resolver( new Resolver( ResPool::instance()) ) { - MIL << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl; - MIL << "defaultTextLocale: '" << ZConfig::instance().textLocale() << "'" << endl; - MIL << "System architecture is '" << ZConfig::instance().systemArchitecture() << "'" << endl; + ZConfig::instance().about( MIL ); MIL << "Initializing keyring..." << std::endl; _keyring = new KeyRing(tmpPath()); }