aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-05 18:37:06 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-05 18:37:06 +0000
commit7635b115fcc17ee50443c35027aa096fd3c3014f (patch)
tree9bb277daa7b660ea33238d4b252d4883c6ac1638
parent823711f892deff3fb19fecf82b59a7be6739ac5d (diff)
downloadpaludis-7635b115fcc17ee50443c35027aa096fd3c3014f.tar.gz
paludis-7635b115fcc17ee50443c35027aa096fd3c3014f.tar.xz
Don't display context with all log messages, only the ones where it's useful
-rw-r--r--ebuild/utils/merge.cc15
-rw-r--r--ebuild/utils/unmerge.cc16
-rw-r--r--paludis/default_config.cc4
-rw-r--r--paludis/default_environment.cc20
-rw-r--r--paludis/dep_atom.cc3
-rw-r--r--paludis/dep_list.cc16
-rw-r--r--paludis/ebuild.cc2
-rw-r--r--paludis/environment.cc3
-rw-r--r--paludis/nothing_repository.cc2
-rw-r--r--paludis/portage_repository.cc66
-rw-r--r--paludis/util/log.cc8
-rw-r--r--paludis/util/log.hh14
-rw-r--r--paludis/util/log_TEST.cc6
-rw-r--r--paludis/util/pstream.cc11
-rw-r--r--paludis/util/system.cc6
-rw-r--r--paludis/vdb_repository.cc33
-rw-r--r--src/install.cc3
-rw-r--r--src/list.cc3
18 files changed, 137 insertions, 94 deletions
diff --git a/ebuild/utils/merge.cc b/ebuild/utils/merge.cc
index ea076fc..23cb64a 100644
--- a/ebuild/utils/merge.cc
+++ b/ebuild/utils/merge.cc
@@ -213,7 +213,7 @@ namespace
if (dst_dir.is_directory())
/* nothing */;
else if (dst_dir.is_symbolic_link() && dst_dir.realpath().is_directory())
- Log::get_instance()->message(ll_qa, "Expected '" + stringify(dst_dir) +
+ Log::get_instance()->message(ll_qa, lc_no_context, "Expected '" + stringify(dst_dir) +
"' to be a directory or non-existent, but found a symlink to a directory");
else if (dst_dir.exists())
throw Failure("Expected '" + stringify(dst_dir) +
@@ -367,7 +367,7 @@ namespace
if (0 != ::symlink(src.readlink().c_str(), stringify(dst).c_str()))
{
- Log::get_instance()->message(ll_warning, "Couldn't create symlink '"
+ Log::get_instance()->message(ll_warning, lc_no_context, "Couldn't create symlink '"
+ src.readlink() + "' at '" + stringify(dst) + "'");
exit_status |= 2;
}
@@ -416,7 +416,8 @@ main(int argc, char * argv[])
#ifdef HAVE_SELINUX
// If the MatchPathCon initialisation fails, don't attempt to match contexts when merging.
if (! MatchPathCon::get_instance()->good())
- Log::get_instance()->message(ll_warning, "matchpathcon_init failed; not setting security contexts");
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "matchpathcon_init failed; not setting security contexts");
#endif
exit_status = 0;
@@ -439,10 +440,10 @@ main(int argc, char * argv[])
else
throw Failure("bad value for log level");
- Log::get_instance()->message(ll_debug, "CONFIG_PROTECT is " + getenv_with_default(
- "CONFIG_PROTECT", "(unset)"));
- Log::get_instance()->message(ll_debug, "CONFIG_PROTECT_MASK is " + getenv_with_default(
- "CONFIG_PROTECT_MASK", "(unset)"));
+ Log::get_instance()->message(ll_debug, lc_no_context,
+ "CONFIG_PROTECT is " + getenv_with_default("CONFIG_PROTECT", "(unset)"));
+ Log::get_instance()->message(ll_debug, lc_no_context,
+ "CONFIG_PROTECT_MASK is " + getenv_with_default("CONFIG_PROTECT_MASK", "(unset)"));
FSEntry src(argv[1]), dst(argv[2]), contents(argv[3]);
diff --git a/ebuild/utils/unmerge.cc b/ebuild/utils/unmerge.cc
index 4f217d5..fe455a0 100644
--- a/ebuild/utils/unmerge.cc
+++ b/ebuild/utils/unmerge.cc
@@ -74,7 +74,8 @@ namespace
{
if (tokens.size() != 4)
{
- Log::get_instance()->message(ll_warning, "Malformed VDB entry '" + *cur + "'");
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Malformed VDB entry '" + *cur + "'");
exit_status |= 4;
}
else if (! (root / tokens.at(1)).is_regular_file())
@@ -86,8 +87,8 @@ namespace
ifstream md5_file(stringify(root / tokens.at(1)).c_str());
if (! md5_file)
{
- Log::get_instance()->message(ll_warning, "Couldn't get md5 for '" +
- stringify(root / tokens.at(1)) + "'");
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Couldn't get md5 for '" + stringify(root / tokens.at(1)) + "'");
cout << "--- [!md5?] " << tokens.at(1) << endl;
}
else if (MD5(md5_file).hexsum() != tokens.at(2))
@@ -105,7 +106,8 @@ namespace
{
if (tokens.size() != 5)
{
- Log::get_instance()->message(ll_warning, "Malformed VDB entry '" + *cur + "'");
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Malformed VDB entry '" + *cur + "'");
exit_status |= 4;
}
else if (! (root / tokens.at(1)).is_symbolic_link())
@@ -128,7 +130,8 @@ namespace
/* nothing */ ;
else
{
- Log::get_instance()->message(ll_warning, "Skipping unknown VDB entry '" + *cur + "'");
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Skipping unknown VDB entry '" + *cur + "'");
exit_status |= 2;
}
}
@@ -150,7 +153,8 @@ namespace
{
if (tokens.size() != 2)
{
- Log::get_instance()->message(ll_warning, "Malformed VDB entry '" + *cur + "'");
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Malformed VDB entry '" + *cur + "'");
exit_status |= 8;
}
else if (! (root / tokens.at(1)).is_directory())
diff --git a/paludis/default_config.cc b/paludis/default_config.cc
index aaa3d75..885b29d 100644
--- a/paludis/default_config.cc
+++ b/paludis/default_config.cc
@@ -127,7 +127,7 @@ DefaultConfig::DefaultConfig() :
if (! config_dir.exists())
throw DefaultConfigError("Can't find configuration directory");
- Log::get_instance()->message(ll_debug, "DefaultConfig initial directory is '"
+ Log::get_instance()->message(ll_debug, lc_no_context, "DefaultConfig initial directory is '"
+ stringify(config_dir) + "'");
if ((config_dir / "specpath").exists())
@@ -151,7 +151,7 @@ DefaultConfig::DefaultConfig() :
std::map<std::string, std::string> conf_vars;
conf_vars.insert(std::make_pair("ROOT", root_prefix));
- Log::get_instance()->message(ll_debug, "DefaultConfig real directory is '"
+ Log::get_instance()->message(ll_debug, lc_no_context, "DefaultConfig real directory is '"
+ stringify(config_dir) + "', root prefix is '" + root_prefix +
"', config suffix is '" + config_suffix + "'");
diff --git a/paludis/default_environment.cc b/paludis/default_environment.cc
index baae411..6d2d32f 100644
--- a/paludis/default_environment.cc
+++ b/paludis/default_environment.cc
@@ -339,17 +339,17 @@ namespace
FSEntry r(base);
if (r.is_directory())
{
- Log::get_instance()->message(ll_debug, "Adding hook directory '"
+ Log::get_instance()->message(ll_debug, lc_no_context, "Adding hook directory '"
+ base + "'");
result.push_back(r);
}
else
- Log::get_instance()->message(ll_debug, "Skipping hook directory candidate '"
+ Log::get_instance()->message(ll_debug, lc_no_context, "Skipping hook directory candidate '"
+ base + "'");
}
catch (const FSError & e)
{
- Log::get_instance()->message(ll_warning, "Caught exception '" +
+ Log::get_instance()->message(ll_warning, lc_no_context, "Caught exception '" +
e.message() + "' (" + e.what() + ") when checking hook "
"directory '" + base + "'");
}
@@ -387,7 +387,7 @@ namespace
{
Context context("When running hook script '" + stringify(f) +
"' for hook '" + hook.name() + "':");
- Log::get_instance()->message(ll_debug, "Starting hook script '" +
+ Log::get_instance()->message(ll_debug, lc_no_context, "Starting hook script '" +
stringify(f) + "' for '" + hook.name() + "'");
MakeEnvCommand cmd(make_env_command("bash '" + stringify(f) + "'")
@@ -403,10 +403,10 @@ namespace
int exit_status(run_command(cmd));
if (0 == exit_status)
- Log::get_instance()->message(ll_debug, "Hook '" + stringify(f)
+ Log::get_instance()->message(ll_debug, lc_no_context, "Hook '" + stringify(f)
+ "' returned success '" + stringify(exit_status) + "'");
else
- Log::get_instance()->message(ll_warning, "Hook '" + stringify(f)
+ Log::get_instance()->message(ll_warning, lc_no_context, "Hook '" + stringify(f)
+ "' returned failure '" + stringify(exit_status) + "'");
}
};
@@ -416,7 +416,7 @@ void
DefaultEnvironment::perform_hook(const Hook & hook) const
{
Context context("When triggering hook '" + hook.name() + "'");
- Log::get_instance()->message(ll_debug, "Starting hook '" + hook.name() + "'");
+ Log::get_instance()->message(ll_debug, lc_no_context, "Starting hook '" + hook.name() + "'");
const std::list<FSEntry> & hook_dirs(get_hook_dirs());
@@ -464,7 +464,7 @@ DefaultEnvironment::local_package_set(const std::string & s,
if (1 == tokens.size())
{
- Log::get_instance()->message(ll_warning, "Line '" + *line + "' in set file '"
+ Log::get_instance()->message(ll_warning, lc_context, "Line '" + *line + "' in set file '"
+ stringify(ff) + "' does not specify '*' or '?', assuming '*'");
PackageDepAtom::Pointer atom(new PackageDepAtom(tokens.at(0)));
atom->set_tag(tag);
@@ -486,11 +486,11 @@ DefaultEnvironment::local_package_set(const std::string & s,
result->add_child(p);
}
else
- Log::get_instance()->message(ll_warning, "Line '" + *line + "' in set file '"
+ Log::get_instance()->message(ll_warning, lc_context, "Line '" + *line + "' in set file '"
+ stringify(ff) + "' does not start with '*' or '?' token, skipping");
if (tokens.size() > 2)
- Log::get_instance()->message(ll_warning, "Line '" + *line + "' in set file '"
+ Log::get_instance()->message(ll_warning, lc_context, "Line '" + *line + "' in set file '"
+ stringify(ff) + "' has trailing garbage");
}
diff --git a/paludis/dep_atom.cc b/paludis/dep_atom.cc
index d8b79f1..c8c03d9 100644
--- a/paludis/dep_atom.cc
+++ b/paludis/dep_atom.cc
@@ -187,7 +187,8 @@ PackageDepAtom::PackageDepAtom(const std::string & ss) :
if ('*' == s.at(s.length() - 1))
{
if (_version_operator != vo_equal)
- Log::get_instance()->message(ll_qa, "Package dep atom '" + ss + "' uses * "
+ Log::get_instance()->message(ll_qa, lc_context,
+ "Package dep atom '" + ss + "' uses * "
"with operator '" + stringify(_version_operator) +
"', pretending it uses the equals operator instead");
_version_operator = vo_equal_star;
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 759bb89..d715f86 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -357,7 +357,7 @@ DepList::visit(const PackageDepAtom * const p)
else if (_imp->drop_circular)
{
if (_imp->current_package)
- Log::get_instance()->message(ll_warning, "Dropping circular dependency on " +
+ Log::get_instance()->message(ll_warning, lc_context, "Dropping circular dependency on " +
stringify(_imp->current_package->get<dle_name>()) + "-" +
stringify(_imp->current_package->get<dle_version>()));
return;
@@ -366,7 +366,7 @@ DepList::visit(const PackageDepAtom * const p)
else if (_imp->current_package && _imp->drop_self_circular &&
match_package(_imp->environment, p, _imp->current_package))
{
- Log::get_instance()->message(ll_warning, "Dropping self-circular dependency on " +
+ Log::get_instance()->message(ll_warning, lc_context, "Dropping self-circular dependency on " +
stringify(_imp->current_package->get<dle_name>()) + "-" +
stringify(_imp->current_package->get<dle_version>()));
return;
@@ -520,7 +520,7 @@ DepList::visit(const PackageDepAtom * const p)
if (dlro_never == _imp->rdepend_post)
throw;
else if (_imp->current_package)
- Log::get_instance()->message(ll_warning, "Couldn't resolve runtime dependencies "
+ Log::get_instance()->message(ll_warning, lc_context, "Couldn't resolve runtime dependencies "
"for " + stringify(_imp->current_package->get<dle_name>()) + "-" +
stringify(_imp->current_package->get<dle_version>()) + " as build dependencies, "
"trying them as post dependencies");
@@ -595,7 +595,7 @@ DepList::visit(const AnyDepAtom * const a)
if (viable_children.empty())
{
if (_imp->current_package)
- Log::get_instance()->message(ll_qa, "Package '" + stringify(*_imp->current_package)
+ Log::get_instance()->message(ll_qa, lc_context, "Package '" + stringify(*_imp->current_package)
+ "' has suspicious || ( ) block that resolves to empty");
return;
}
@@ -675,7 +675,7 @@ DepList::visit(const BlockDepAtom * const d)
{
if (_imp->current_package->get<dle_name>() == ii->get<pde_name>())
{
- Log::get_instance()->message(ll_qa, "Package '" + stringify(*_imp->current_package)
+ Log::get_instance()->message(ll_qa, lc_context, "Package '" + stringify(*_imp->current_package)
+ "' has suspicious block upon '!" + stringify(*d->blocked_atom()) + "'");
continue;
}
@@ -704,7 +704,7 @@ DepList::visit(const BlockDepAtom * const d)
}
if (skip)
- Log::get_instance()->message(ll_qa, "Ignoring block on '" +
+ Log::get_instance()->message(ll_qa, lc_context, "Ignoring block on '" +
stringify(*(d->blocked_atom())) + "' in '" +
stringify(*_imp->current_package) +
"' which is blocked by installed package '" + stringify(*ii) +
@@ -729,7 +729,7 @@ DepList::visit(const BlockDepAtom * const d)
if (*_imp->current_package == *m)
{
- Log::get_instance()->message(ll_qa, "Package '" + stringify(*_imp->current_package)
+ Log::get_instance()->message(ll_qa,lc_context, "Package '" + stringify(*_imp->current_package)
+ "' has suspicious block upon '!" + stringify(*d->blocked_atom()) + "'");
++m;
continue;
@@ -759,7 +759,7 @@ DepList::visit(const BlockDepAtom * const d)
}
if (skip)
- Log::get_instance()->message(ll_qa, "Ignoring block on '" +
+ Log::get_instance()->message(ll_qa, lc_context, "Ignoring block on '" +
stringify(*(d->blocked_atom())) + "' in '" +
stringify(*_imp->current_package) +
"' which is blocked by pending package '" + stringify(*m) +
diff --git a/paludis/ebuild.cc b/paludis/ebuild.cc
index 050bac9..de86e81 100644
--- a/paludis/ebuild.cc
+++ b/paludis/ebuild.cc
@@ -196,7 +196,7 @@ EbuildMetadataCommand::do_run_command(const std::string & cmd)
return true;
else
{
- Log::get_instance()->message(ll_warning, "Could not generate cache for '"
+ Log::get_instance()->message(ll_warning, lc_context, "Could not generate cache for '"
+ stringify(*params.get<ecpk_db_entry>()) + "'");
_metadata->set<vm_eapi>("UNKNOWN");
diff --git a/paludis/environment.cc b/paludis/environment.cc
index 80115f8..1def7aa 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -345,7 +345,8 @@ Environment::add_appropriate_to_world(DepAtom::ConstPointer a) const
i_end(w.items.end()) ; i != i_end ; ++i)
{
if (! package_database()->query(**i, is_installed_only)->empty())
- Log::get_instance()->message(ll_debug, "Not adding '" + stringify(**i) +
+ Log::get_instance()->message(ll_debug, lc_no_context,
+ "Not adding '" + stringify(**i) +
"' to world, because it is already installed");
else
{
diff --git a/paludis/nothing_repository.cc b/paludis/nothing_repository.cc
index 6ccca9d..9bfc68b 100644
--- a/paludis/nothing_repository.cc
+++ b/paludis/nothing_repository.cc
@@ -157,7 +157,7 @@ VersionMetadata::ConstPointer
NothingRepository::do_version_metadata(
const QualifiedPackageName & q, const VersionSpec & v) const
{
- Log::get_instance()->message(ll_warning, "has_version failed for request for '" +
+ Log::get_instance()->message(ll_warning, lc_context, "has_version failed for request for '" +
stringify(q) + "-" + stringify(v) + "' in repository '" +
stringify(name()) + "'");
return VersionMetadata::ConstPointer(new VersionMetadata::Ebuild(
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 792d084..bd13562 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -326,8 +326,8 @@ Implementation<PortageRepository>::add_profile_r(const FSEntry & f) const
if (! f.is_directory())
{
- Log::get_instance()->message(ll_warning, "Profile component '" + stringify(f) +
- "' is not a directory");
+ Log::get_instance()->message(ll_warning, lc_context,
+ "Profile component '" + stringify(f) + "' is not a directory");
return;
}
@@ -340,8 +340,8 @@ Implementation<PortageRepository>::add_profile_r(const FSEntry & f) const
if (it == it_end)
{
- Log::get_instance()->message(ll_warning, "Profile parent file in '" +
- stringify(f) + "' cannot be read");
+ Log::get_instance()->message(ll_warning, lc_context,
+ "Profile parent file in '" + stringify(f) + "' cannot be read");
return;
}
@@ -497,7 +497,8 @@ Implementation<PortageRepository>::add_profile_r(const FSEntry & f) const
else if ('-' == line->at(0) && '*' == line->at(1))
if (0==system_lines.erase(line->substr(2)))
{
- Log::get_instance()->message(ll_qa, "Trying to remove packages line '" + line->substr(2) +
+ Log::get_instance()->message(ll_qa, lc_context,
+ "Trying to remove packages line '" + line->substr(2) +
"' that doesn't exist.");
}
}
@@ -702,7 +703,7 @@ PortageRepository::do_package_names(const CategoryNamePart & c) const
}
catch (const NameError & e)
{
- Log::get_instance()->message(ll_warning, "Skipping entry '" +
+ Log::get_instance()->message(ll_warning, lc_context, "Skipping entry '" +
d->basename() + "' in category '" + stringify(c) + "' in repository '"
+ stringify(name()) + "' (" + e.message() + ")");
}
@@ -816,7 +817,7 @@ PortageRepository::need_version_names(const QualifiedPackageName & n) const
}
catch (const NameError &)
{
- Log::get_instance()->message(ll_warning, "Skipping entry '"
+ Log::get_instance()->message(ll_warning, lc_context, "Skipping entry '"
+ stringify(*e) + "' for '" + stringify(n) + "' in repository '"
+ stringify(name()) + "'");
}
@@ -851,7 +852,7 @@ PortageRepository::fetch_repo_name(const std::string & location)
catch (...)
{
}
- Log::get_instance()->message(ll_qa, "Couldn't open repo_name file in '"
+ Log::get_instance()->message(ll_qa, lc_no_context, "Couldn't open repo_name file in '"
+ location + "/profiles/'. Falling back to a generated name.");
std::string modified_location(FSEntry(location).basename());
@@ -872,7 +873,7 @@ PortageRepository::do_version_metadata(
if (! has_version(q, v))
{
- Log::get_instance()->message(ll_warning, "has_version failed for request for '" +
+ Log::get_instance()->message(ll_warning, lc_context, "has_version failed for request for '" +
stringify(q) + "-" + stringify(v) + "' in repository '" +
stringify(name()) + "'");
return VersionMetadata::ConstPointer(new VersionMetadata::Ebuild(
@@ -942,11 +943,12 @@ PortageRepository::do_version_metadata(
}
if (! ok)
- Log::get_instance()->message(ll_warning, "Stale cache file at '"
+ Log::get_instance()->message(ll_warning, lc_no_context, "Stale cache file at '"
+ stringify(cache_file) + "'");
}
else
- Log::get_instance()->message(ll_warning, "Couldn't read the cache file at '"
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Couldn't read the cache file at '"
+ stringify(cache_file) + "'");
}
else if (_imp->virtuals_map.end() != ((vi = _imp->virtuals_map.find(q))))
@@ -964,7 +966,8 @@ PortageRepository::do_version_metadata(
if (! ok)
{
if (_imp->cache.basename() != "empty")
- Log::get_instance()->message(ll_warning, "No usable cache entry for '" + stringify(q) +
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "No usable cache entry for '" + stringify(q) +
"-" + stringify(v) + "' in '" + stringify(name()) + "'");
PackageDatabaseEntry e(q, v, name());
@@ -981,7 +984,8 @@ PortageRepository::do_version_metadata(
param<ecpk_buildroot>(_imp->buildroot)
)));
if (! cmd())
- Log::get_instance()->message(ll_warning, "No usable metadata for '" + stringify(q)
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "No usable metadata for '" + stringify(q)
+ "-" + stringify(v) + "' in '" + stringify(name()) + "'");
if (0 == ((result = cmd.metadata())))
@@ -1181,7 +1185,8 @@ PortageRepository::make_portage_repository(
create_inserter<FSEntry>(std::back_inserter(*profiles)));
if (m.end() != m.find("profile") && ! m.find("profile")->second.empty())
{
- Log::get_instance()->message(ll_warning, "Key 'profile' in '" + repo_file + "' is deprecated, "
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Key 'profile' in '" + repo_file + "' is deprecated, "
"use 'profiles = " + m.find("profile")->second + "' instead");
if (profiles->empty())
profiles->append(m.find("profile")->second);
@@ -1197,7 +1202,8 @@ PortageRepository::make_portage_repository(
create_inserter<FSEntry>(std::back_inserter(*eclassdirs)));
if (m.end() != m.find("eclassdir") && ! m.find("eclassdir")->second.empty())
{
- Log::get_instance()->message(ll_warning, "Key 'eclassdir' in '" + repo_file + "' is deprecated, "
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Key 'eclassdir' in '" + repo_file + "' is deprecated, "
"use 'eclassdirs = " + m.find("eclassdir")->second + "' instead");
if (eclassdirs->empty())
eclassdirs->append(m.find("eclassdir")->second);
@@ -1338,7 +1344,8 @@ PortageRepository::do_is_mirror(const std::string & s) const
}
}
else
- Log::get_instance()->message(ll_warning, "No thirdpartymirrors file found in '"
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "No thirdpartymirrors file found in '"
+ stringify(_imp->location / "profiles") + "', so mirror:// SRC_URI "
"components cannot be fetched");
@@ -1774,7 +1781,8 @@ PortageRepository::do_security_set(const PackageSetOptions & o) const
}
catch (const AdvisoryFileError & e)
{
- Log::get_instance()->message(ll_warning, "Malformed advisory file '" + stringify(*f) + "': " + e.message());
+ Log::get_instance()->message(ll_warning, lc_context,
+ "Malformed advisory file '" + stringify(*f) + "': " + e.message());
}
catch (const InternalError & e)
{
@@ -1782,7 +1790,8 @@ PortageRepository::do_security_set(const PackageSetOptions & o) const
}
catch (const Exception & e)
{
- Log::get_instance()->message(ll_warning, "Exception caught while parsing advisory '" + stringify(*f) +
+ Log::get_instance()->message(ll_warning, lc_context,
+ "Exception caught while parsing advisory '" + stringify(*f) +
"': " + e.message());
}
@@ -1848,7 +1857,8 @@ PortageRepository::do_package_set(const std::string & s, const PackageSetOptions
if (1 == tokens.size())
{
- Log::get_instance()->message(ll_warning, "Line '" + *line + "' in set file '"
+ Log::get_instance()->message(ll_warning, lc_context,
+ "Line '" + *line + "' in set file '"
+ stringify(ff) + "' does not specify '*' or '?', assuming '*'");
PackageDepAtom::Pointer atom(new PackageDepAtom(tokens.at(0)));
atom->set_tag(tag);
@@ -1870,11 +1880,13 @@ PortageRepository::do_package_set(const std::string & s, const PackageSetOptions
result->add_child(p);
}
else
- Log::get_instance()->message(ll_warning, "Line '" + *line + "' in set file '"
+ Log::get_instance()->message(ll_warning, lc_context,
+ "Line '" + *line + "' in set file '"
+ stringify(ff) + "' does not start with '*' or '?' token, skipping");
if (tokens.size() > 2)
- Log::get_instance()->message(ll_warning, "Line '" + *line + "' in set file '"
+ Log::get_instance()->message(ll_warning, lc_context,
+ "Line '" + *line + "' in set file '"
+ stringify(ff) + "' has trailing garbage");
}
@@ -1993,7 +2005,8 @@ PortageRepository::update_news() const
std::string profile(strip_leading_string(strip_trailing_string(
strip_leading_string(stringify(p->realpath()),
stringify(p->realpath())), "/"), "/"));
- Log::get_instance()->message(ll_debug, "Profile path is '" + profile + "'");
+ Log::get_instance()->message(ll_debug, lc_no_context,
+ "Profile path is '" + profile + "'");
for (NewsFile::DisplayIfProfileIterator i(news.begin_display_if_profile()),
i_end(news.end_display_if_profile()) ; i != i_end ; ++i)
if (profile == *i)
@@ -2006,12 +2019,14 @@ PortageRepository::update_news() const
{
std::ofstream s(stringify(skip_file).c_str(), std::ios::out | std::ios::app);
if (! s)
- Log::get_instance()->message(ll_warning, "Cannot append to news skip file '"
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Cannot append to news skip file '"
+ stringify(skip_file) + "', skipping news item '" + stringify(*d) + "'");
std::ofstream t(stringify(unread_file).c_str(), std::ios::out | std::ios::app);
if (! t)
- Log::get_instance()->message(ll_warning, "Cannot append to unread file '"
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Cannot append to unread file '"
+ stringify(unread_file) + "', skipping news item '" + stringify(*d) + "'");
if (s && t)
@@ -2023,7 +2038,8 @@ PortageRepository::update_news() const
}
catch (const ConfigFileError & e)
{
- Log::get_instance()->message(ll_warning, "Skipping news item '"
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Skipping news item '"
+ stringify(*d) + "' because of exception '" + e.message() + "' ("
+ e.what() + ")");
}
diff --git a/paludis/util/log.cc b/paludis/util/log.cc
index 8ac4d39..8ef0510 100644
--- a/paludis/util/log.cc
+++ b/paludis/util/log.cc
@@ -75,7 +75,7 @@ Log::log_level() const
}
void
-Log::message(const LogLevel l, const std::string & s)
+Log::message(const LogLevel l, const LogContext c, const std::string & s)
{
if (l >= _imp->log_level)
{
@@ -107,7 +107,10 @@ Log::message(const LogLevel l, const std::string & s)
} while (false);
- *_imp->stream << Context::backtrace(" ") << s << std::endl;
+ if (lc_context == c)
+ *_imp->stream << Context::backtrace(" ") << s << std::endl;
+ else
+ *_imp->stream << s << std::endl;
}
}
@@ -146,4 +149,3 @@ Log::set_program_name(const std::string & s)
{
_imp->program_name = s;
}
-
diff --git a/paludis/util/log.hh b/paludis/util/log.hh
index ce3a364..3bd859b 100644
--- a/paludis/util/log.hh
+++ b/paludis/util/log.hh
@@ -55,6 +55,18 @@ namespace paludis
};
/**
+ * Specifies whether a log message has context.
+ *
+ * \ingroup grplog
+ */
+ enum LogContext
+ {
+ lc_no_context,
+ lc_context,
+ last_lc
+ };
+
+ /**
* Singleton class that handles log messages.
*
* \ingroup grplog
@@ -87,7 +99,7 @@ namespace paludis
/**
* Log a message at the specified level.
*/
- void message(const LogLevel, const std::string &);
+ void message(const LogLevel, const LogContext, const std::string &);
/**
* Change the log stream.
diff --git a/paludis/util/log_TEST.cc b/paludis/util/log_TEST.cc
index 4671670..ed8fc0a 100644
--- a/paludis/util/log_TEST.cc
+++ b/paludis/util/log_TEST.cc
@@ -52,7 +52,7 @@ namespace test_cases
Log::get_instance()->set_log_level(ll_debug);
TEST_CHECK(s.str().empty());
- Log::get_instance()->message(ll_debug, "one");
+ Log::get_instance()->message(ll_debug, lc_no_context, "one");
TEST_CHECK(! s.str().empty());
TEST_CHECK(std::string::npos != s.str().find("one"));
@@ -61,9 +61,9 @@ namespace test_cases
TEST_CHECK(t.str().empty());
Log::get_instance()->set_log_level(ll_warning);
- Log::get_instance()->message(ll_debug, "two");
+ Log::get_instance()->message(ll_debug, lc_no_context, "two");
TEST_CHECK(t.str().empty());
- Log::get_instance()->message(ll_warning, "three");
+ Log::get_instance()->message(ll_warning, lc_no_context, "three");
TEST_CHECK(! t.str().empty());
TEST_CHECK(std::string::npos == t.str().find("one"));
TEST_CHECK(std::string::npos == t.str().find("two"));
diff --git a/paludis/util/pstream.cc b/paludis/util/pstream.cc
index 4ee8dea..940b4d2 100644
--- a/paludis/util/pstream.cc
+++ b/paludis/util/pstream.cc
@@ -64,8 +64,8 @@ PStreamInBuf::PStreamInBuf(const std::string & command) :
_command(command),
fd(popen(command.c_str(), "r"))
{
- Log::get_instance()->message(ll_debug, "popen " + command + " -> " + stringify(
- fileno(fd)));
+ Log::get_instance()->message(ll_debug, lc_no_context,
+ "popen " + command + " -> " + stringify(fileno(fd)));
if (0 == fd)
throw PStreamError("popen('" + _command + "', 'r') failed: " +
@@ -79,7 +79,8 @@ PStreamInBuf::~PStreamInBuf()
if (0 != fd)
{
int fdn = fileno(fd), x = pclose(fd);
- Log::get_instance()->message(ll_debug, "pclose " + stringify(fdn) + " -> " + stringify(x));
+ Log::get_instance()->message(ll_debug, lc_no_context,
+ "pclose " + stringify(fdn) + " -> " + stringify(x));
}
}
@@ -91,8 +92,8 @@ PStreamInBuf::exit_status()
int fdn = fileno(fd);
_exit_status = pclose(fd);
fd = 0;
- Log::get_instance()->message(ll_debug, "manual pclose " + stringify(fdn) + " -> " + stringify(
- _exit_status));
+ Log::get_instance()->message(ll_debug, lc_no_context,
+ "manual pclose " + stringify(fdn) + " -> " + stringify(_exit_status));
}
return _exit_status;
}
diff --git a/paludis/util/system.cc b/paludis/util/system.cc
index 2ca6d7b..6cc12b4 100644
--- a/paludis/util/system.cc
+++ b/paludis/util/system.cc
@@ -55,7 +55,7 @@ namespace
if (-1 == chdir(stringify(*fsentry).c_str()))
throw RunCommandError("chdir failed: " + stringify(strerror(errno)));
- Log::get_instance()->message(ll_debug, "execl /bin/sh -c " + cmd);
+ Log::get_instance()->message(ll_debug, lc_no_context, "execl /bin/sh -c " + cmd);
execl("/bin/sh", "sh", "-c", cmd.c_str(), static_cast<char *>(0));
throw RunCommandError("execl /bin/sh -c '" + cmd + "' failed:"
+ stringify(strerror(errno)));
@@ -173,8 +173,8 @@ paludis::make_sandbox_command(const std::string & cmd)
#if HAVE_SANDBOX
if (! getenv_with_default("SANDBOX_ACTIVE", "").empty())
{
- Log::get_instance()->message(ll_warning, "Already inside sandbox, not spawning "
- "another sandbox instance");
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Already inside sandbox, not spawning another sandbox instance");
return cmd;
}
else
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index a94f4bc..ea1384a 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -371,7 +371,7 @@ Implementation<VDBRepository>::load_entry(std::vector<VDBEntry>::iterator p) con
std::string slot(file_contents(location, p->name, p->version, "SLOT"));
if (slot.empty())
{
- Log::get_instance()->message(ll_warning, "VDBRepository entry '" +
+ Log::get_instance()->message(ll_warning, lc_no_context, "VDBRepository entry '" +
stringify(p->name) + "-" + stringify(p->version) + "' in '" +
stringify(location) + "' has empty SLOT, setting to \"0\"");
slot = "0";
@@ -526,7 +526,7 @@ VDBRepository::do_version_metadata(
if (r.first == r.second)
{
- Log::get_instance()->message(ll_warning, "version lookup failed for request for '" +
+ Log::get_instance()->message(ll_warning, lc_context, "version lookup failed for request for '" +
stringify(q) + "-" + stringify(v) + "' in repository '" +
stringify(name()) + "'");
return VersionMetadata::ConstPointer(new VersionMetadata(&PortageDepParser::parse_depend));
@@ -555,7 +555,8 @@ VDBRepository::do_contents(
if (r.first == r.second)
{
- Log::get_instance()->message(ll_warning, "version lookup failed for request for '" +
+ Log::get_instance()->message(ll_warning, lc_context,
+ "version lookup failed for request for '" +
stringify(q) + "-" + stringify(v) + "' in repository '" +
stringify(name()) + "'");
return Contents::ConstPointer(new Contents);
@@ -567,7 +568,8 @@ VDBRepository::do_contents(
(stringify(q.get<qpn_package>()) + "-" + stringify(v)));
if (! (f / "CONTENTS").is_regular_file())
{
- Log::get_instance()->message(ll_warning, "CONTENTS lookup failed for request for '" +
+ Log::get_instance()->message(ll_warning, lc_context,
+ "CONTENTS lookup failed for request for '" +
stringify(q) + "-" + stringify(v) + "' in vdb '" +
stringify(_imp->location) + "'");
return result;
@@ -590,7 +592,7 @@ VDBRepository::do_contents(
if (tokens.size() < 2)
{
- Log::get_instance()->message(ll_warning, "CONTENTS for '" +
+ Log::get_instance()->message(ll_warning, lc_no_context, "CONTENTS for '" +
stringify(q) + "-" + stringify(v) + "' in vdb '" +
stringify(_imp->location) + "' has broken line " +
stringify(line_number) + ", skipping");
@@ -607,7 +609,7 @@ VDBRepository::do_contents(
{
if (tokens.size() < 4)
{
- Log::get_instance()->message(ll_warning, "CONTENTS for '" +
+ Log::get_instance()->message(ll_warning, lc_no_context, "CONTENTS for '" +
stringify(q) + "-" + stringify(v) + "' in vdb '" +
stringify(_imp->location) + "' has broken sym line " +
stringify(line_number) + ", skipping");
@@ -825,7 +827,8 @@ VDBRepository::do_package_set(const std::string & s, const PackageSetOptions &)
}
}
else
- Log::get_instance()->message(ll_warning, "World file '" + stringify(_imp->world_file) +
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "World file '" + stringify(_imp->world_file) +
"' doesn't exist");
return result;
@@ -847,7 +850,7 @@ VDBRepository::begin_provide_map() const
{
Context context("When loading VDB PROVIDEs map:");
- Log::get_instance()->message(ll_debug, "Starting VDB PROVIDEs map creation");
+ Log::get_instance()->message(ll_debug, lc_no_context, "Starting VDB PROVIDEs map creation");
if (! _imp->entries_valid)
_imp->load_entries();
@@ -876,7 +879,7 @@ VDBRepository::begin_provide_map() const
QualifiedPackageName pp((*p)->text());
if (pp.get<qpn_category>() != CategoryNamePart("virtual"))
- Log::get_instance()->message(ll_warning, "PROVIDE of non-virtual '"
+ Log::get_instance()->message(ll_warning, lc_no_context, "PROVIDE of non-virtual '"
+ stringify(pp) + "' from '" + stringify(e->name) + "-"
+ stringify(e->version) + "' in '" + stringify(name())
+ "' will not work as expected");
@@ -890,13 +893,13 @@ VDBRepository::begin_provide_map() const
}
catch (const Exception & ee)
{
- Log::get_instance()->message(ll_warning, "Skipping VDB PROVIDE entry for '"
+ Log::get_instance()->message(ll_warning, lc_no_context, "Skipping VDB PROVIDE entry for '"
+ stringify(e->name) + "-" + stringify(e->version) + "' due to exception '"
+ stringify(ee.message()) + "' (" + stringify(ee.what()) + ")");
}
}
- Log::get_instance()->message(ll_debug, "Done VDB PROVIDEs map creation");
+ Log::get_instance()->message(ll_debug, lc_no_context, "Done VDB PROVIDEs map creation");
_imp->has_provide_map = true;
}
@@ -932,7 +935,7 @@ VDBRepository::add_to_world(const QualifiedPackageName & n) const
{
std::ofstream world(stringify(_imp->world_file).c_str(), std::ios::out | std::ios::app);
if (! world)
- Log::get_instance()->message(ll_warning, "Cannot append to world file '"
+ Log::get_instance()->message(ll_warning, lc_no_context, "Cannot append to world file '"
+ stringify(_imp->world_file) + "', skipping world update");
else
world << n << std::endl;
@@ -950,7 +953,7 @@ VDBRepository::remove_from_world(const QualifiedPackageName & n) const
if (! world_file)
{
- Log::get_instance()->message(ll_warning, "Cannot read world file '"
+ Log::get_instance()->message(ll_warning, lc_no_context, "Cannot read world file '"
+ stringify(_imp->world_file) + "', skipping world update");
return;
}
@@ -961,7 +964,7 @@ VDBRepository::remove_from_world(const QualifiedPackageName & n) const
if (strip_leading(strip_trailing(line, " \t"), "\t") != stringify(n))
world_lines.push_back(line);
else
- Log::get_instance()->message(ll_debug, "Removing line '"
+ Log::get_instance()->message(ll_debug, lc_no_context, "Removing line '"
+ line + "' from world file '" + stringify(_imp->world_file));
}
}
@@ -970,7 +973,7 @@ VDBRepository::remove_from_world(const QualifiedPackageName & n) const
if (! world_file)
{
- Log::get_instance()->message(ll_warning, "Cannot write world file '"
+ Log::get_instance()->message(ll_warning, lc_no_context, "Cannot write world file '"
+ stringify(_imp->world_file) + "', skipping world update");
return;
}
diff --git a/src/install.cc b/src/install.cc
index d981bdc..be369aa 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -290,7 +290,8 @@ do_install()
if (max_count != new_count + upgrade_count + downgrade_count + new_slot_count +
rebuild_count)
- p::Log::get_instance()->message(p::ll_warning, "Max count doesn't add up. This is a bug!");
+ p::Log::get_instance()->message(p::ll_warning, p::lc_no_context,
+ "Max count doesn't add up. This is a bug!");
cout << endl << "Total: " << max_count << (max_count == 1 ? " package" : " packages");
if (max_count)
diff --git a/src/list.cc b/src/list.cc
index f714921..d1072b6 100644
--- a/src/list.cc
+++ b/src/list.cc
@@ -231,7 +231,8 @@ namespace
void
VulnerabilitiesPrinter::visit(const p::UseDepAtom * const a)
{
- p::Log::get_instance()->message(p::ll_warning, "UseDepAtom encounter in do_package_set(\"security\").");
+ p::Log::get_instance()->message(p::ll_warning, p::lc_no_context,
+ "UseDepAtom encounter in do_package_set(\"security\").");
std::for_each(a->begin(), a->end(), p::accept_visitor(this));
}