aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-06 00:19:59 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-06 00:19:59 +0000
commit69612ab816a7e3832f5ae053bd55c40c367bc7d8 (patch)
treee74c0a39f1a32122b85d26148513faeced4a1a60
parentd946b89871e6dad288440d5fd1ad29bfcd1dff1d (diff)
downloadpaludis-69612ab816a7e3832f5ae053bd55c40c367bc7d8.tar.gz
paludis-69612ab816a7e3832f5ae053bd55c40c367bc7d8.tar.xz
More general OutputManager framework.
-rw-r--r--doc/api/cplusplus/examples/example_action.cc2
-rw-r--r--paludis/action.hh15
-rw-r--r--paludis/install_task.cc28
-rw-r--r--paludis/repositories/cran/cran_repository.cc49
-rw-r--r--paludis/repositories/cran/cran_repository.hh4
-rw-r--r--paludis/repositories/e/check_fetched_files_visitor.cc76
-rw-r--r--paludis/repositories/e/check_fetched_files_visitor.hh6
-rw-r--r--paludis/repositories/e/e_repository.cc5
-rw-r--r--paludis/repositories/e/e_repository.hh4
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc11
-rw-r--r--paludis/repositories/e/e_repository_TEST_ever.cc3
-rw-r--r--paludis/repositories/e/ebuild.cc9
-rw-r--r--paludis/repositories/e/ebuild.hh4
-rw-r--r--paludis/repositories/e/ebuild_entries.cc6
-rw-r--r--paludis/repositories/e/exndbam_repository_TEST.cc3
-rw-r--r--paludis/repositories/e/fetch_visitor.cc21
-rw-r--r--paludis/repositories/e/fetch_visitor.hh6
-rw-r--r--paludis/repositories/e/fetch_visitor_TEST.cc3
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc7
-rw-r--r--paludis/repositories/unavailable/unavailable_repository.cc7
-rw-r--r--paludis/repositories/unavailable/unavailable_repository.hh4
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc4
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository_TEST.cc3
-rw-r--r--paludis/repositories/unwritten/unwritten_repository.cc7
-rw-r--r--paludis/repositories/unwritten/unwritten_repository.hh4
-rw-r--r--paludis/repository.hh5
-rw-r--r--paludis/syncer.cc16
-rw-r--r--paludis/syncer.hh13
-rw-r--r--paludis/util/files.m43
-rw-r--r--paludis/util/log.hh11
-rw-r--r--paludis/util/output_deviator.cc144
-rw-r--r--paludis/util/output_deviator.hh71
-rw-r--r--paludis/util/output_manager-fwd.hh (renamed from paludis/util/output_deviator-fwd.hh)9
-rw-r--r--paludis/util/output_manager.cc27
-rw-r--r--paludis/util/output_manager.hh43
-rw-r--r--paludis/util/standard_output_manager-fwd.hh28
-rw-r--r--paludis/util/standard_output_manager.cc50
-rw-r--r--paludis/util/standard_output_manager.hh43
-rw-r--r--python/action.cc4
-rw-r--r--ruby/action.cc4
-rw-r--r--src/clients/accerso/accerso.cc5
-rw-r--r--src/clients/appareo/appareo.cc5
-rw-r--r--src/clients/cave/cmd_sync.cc80
43 files changed, 432 insertions, 420 deletions
diff --git a/doc/api/cplusplus/examples/example_action.cc b/doc/api/cplusplus/examples/example_action.cc
index fc3f83d..d62f9df 100644
--- a/doc/api/cplusplus/examples/example_action.cc
+++ b/doc/api/cplusplus/examples/example_action.cc
@@ -63,7 +63,7 @@ int main(int argc, char * argv[])
FetchAction fetch_action(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(false),
value_for<n::fetch_unneeded>(false),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::output_manager>(new StandardOutputManager()),
value_for<n::safe_resume>(true)
));
try
diff --git a/paludis/action.hh b/paludis/action.hh
index 4cbbd1c..f2389b4 100644
--- a/paludis/action.hh
+++ b/paludis/action.hh
@@ -30,7 +30,7 @@
#include <paludis/util/sequence-fwd.hh>
#include <paludis/util/named_value.hh>
#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/util/output_deviator-fwd.hh>
+#include <paludis/util/output_manager-fwd.hh>
#include <paludis/util/type_list.hh>
#include <tr1/functional>
@@ -54,7 +54,7 @@ namespace paludis
struct failed_automatic_fetching;
struct failed_integrity_checks;
struct fetch_unneeded;
- struct maybe_output_deviant;
+ struct output_manager;
struct requires_manual_fetching;
struct safe_resume;
struct target_file;
@@ -79,10 +79,9 @@ namespace paludis
NamedValue<n::fetch_unneeded, bool> fetch_unneeded;
/**
- * May be an empty pointer, for no deviation.
- * \since 0.32
+ * \since 0.36
*/
- NamedValue<n::maybe_output_deviant, std::tr1::shared_ptr<OutputDeviant> > maybe_output_deviant;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
NamedValue<n::safe_resume, bool> safe_resume;
};
@@ -97,6 +96,12 @@ namespace paludis
struct InstallActionOptions
{
NamedValue<n::destination, std::tr1::shared_ptr<Repository> > destination;
+
+ /**
+ * \since 0.36
+ */
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
+
NamedValue<n::used_this_for_config_protect, std::tr1::function<void (const std::string &)> > used_this_for_config_protect;
NamedValue<n::want_phase, std::tr1::function<WantPhase (const std::string &)> > want_phase;
};
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index 5fadd75..4a2c7ee 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -49,6 +49,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <paludis/handled_information.hh>
#include <tr1/functional>
#include <sstream>
@@ -116,7 +117,6 @@ namespace paludis
Environment * const env;
DepList dep_list;
FetchActionOptions fetch_options;
- InstallActionOptions install_options;
std::string config_protect;
@@ -153,17 +153,9 @@ namespace paludis
make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(false),
value_for<n::fetch_unneeded>(false),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::safe_resume>(false)
)),
- install_options(
- make_named_values<InstallActionOptions>(
- value_for<n::destination>(std::tr1::shared_ptr<Repository>()),
- value_for<n::used_this_for_config_protect>(std::tr1::bind(
- &Implementation<InstallTask>::assign_config_protect,
- this, std::tr1::placeholders::_1)),
- value_for<n::want_phase>(std::tr1::function<WantPhase (const std::string &)>())
- )),
config_protect(""),
targets(new SetSpecTree(make_shared_ptr(new AllDepSpec))),
destinations(d),
@@ -768,8 +760,16 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
if (! _imp->fetch_only)
{
+ InstallActionOptions install_options(make_named_values<InstallActionOptions>(
+ value_for<n::destination>(dep->destination()),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
+ value_for<n::used_this_for_config_protect>(std::tr1::bind(
+ &Implementation<InstallTask>::assign_config_protect,
+ _imp.get(), std::tr1::placeholders::_1)),
+ value_for<n::want_phase>(std::tr1::function<WantPhase (const std::string &)>())
+ ));
+
bool done_any(false);
- _imp->install_options.destination() = dep->destination();
bool apply_phases(false);
if (! _imp->abort_at_phases->empty() || ! _imp->skip_phases->empty() || ! _imp->skip_until_phases->empty())
@@ -782,14 +782,14 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
apply_phases = true;
}
if (apply_phases)
- _imp->install_options.want_phase() = std::tr1::bind(&want_phase_function, this,
+ install_options.want_phase() = std::tr1::bind(&want_phase_function, this,
std::tr1::cref(_imp->abort_at_phases), std::tr1::cref(_imp->skip_phases), std::tr1::cref(_imp->skip_until_phases),
std::tr1::ref(done_any), std::tr1::placeholders::_1);
else
- _imp->install_options.want_phase() = std::tr1::bind(&want_all_phases_function, this,
+ install_options.want_phase() = std::tr1::bind(&want_all_phases_function, this,
std::tr1::ref(done_any), std::tr1::placeholders::_1);
- InstallAction install_action(_imp->install_options);
+ InstallAction install_action(install_options);
dep->package_id()->perform_action(install_action);
}
}
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index 553f1cf..1f63e2e 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -44,9 +44,9 @@
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
-#include <paludis/util/output_deviator.hh>
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/output_manager.hh>
#include <paludis/syncer.hh>
#include <tr1/unordered_map>
#include <tr1/functional>
@@ -368,7 +368,7 @@ CRANRepository::sets_list() const
}
bool
-CRANRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const
+CRANRepository::sync(const std::tr1::shared_ptr<OutputManager> & output_manager) const
{
Context context("When syncing repository '" + stringify(name()) + "':");
Lock l(*_imp->big_nasty_mutex);
@@ -378,17 +378,10 @@ CRANRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_de
Command command1(Command(cmd).with_chdir(_imp->params.location()));
- if (output_deviant)
- command1
- .with_captured_stdout_stream(output_deviant->stdout_stream())
- .with_captured_stderr_stream(output_deviant->stderr_stream())
- ;
- else
- command1
- .with_stdout_prefix("sync " + stringify(name()) + "> ")
- .with_stderr_prefix("sync " + stringify(name()) + "> ")
- .with_prefix_blank_lines()
- ;
+ command1
+ .with_captured_stdout_stream(&output_manager->stdout_stream())
+ .with_captured_stderr_stream(&output_manager->stderr_stream())
+ ;
if (0 != run_command(command1))
throw SyncFailedError(stringify(_imp->params.location()), _imp->params.sync());
@@ -397,17 +390,10 @@ CRANRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_de
Command command2(Command(cmd).with_chdir(_imp->params.location()));
- if (output_deviant)
- command2
- .with_captured_stdout_stream(output_deviant->stdout_stream())
- .with_captured_stderr_stream(output_deviant->stderr_stream())
- ;
- else
- command2
- .with_stdout_prefix("sync " + stringify(name()) + "> ")
- .with_stderr_prefix("sync " + stringify(name()) + "> ")
- .with_prefix_blank_lines()
- ;
+ command2
+ .with_captured_stdout_stream(&output_manager->stdout_stream())
+ .with_captured_stderr_stream(&output_manager->stderr_stream())
+ ;
if (0 != run_command(command2))
throw SyncFailedError(stringify(_imp->params.location()), _imp->params.sync());
@@ -416,17 +402,10 @@ CRANRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_de
Command command3(Command(cmd).with_chdir(_imp->params.location()));
- if (output_deviant)
- command3
- .with_captured_stdout_stream(output_deviant->stdout_stream())
- .with_captured_stderr_stream(output_deviant->stderr_stream())
- ;
- else
- command3
- .with_stdout_prefix("sync " + stringify(name()) + "> ")
- .with_stderr_prefix("sync " + stringify(name()) + "> ")
- .with_prefix_blank_lines()
- ;
+ command3
+ .with_captured_stdout_stream(&output_manager->stdout_stream())
+ .with_captured_stderr_stream(&output_manager->stderr_stream())
+ ;
if (0 != run_command(command3))
throw SyncFailedError(stringify(_imp->params.location()), _imp->params.sync());
diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh
index 6d458af..9baef2a 100644
--- a/paludis/repositories/cran/cran_repository.hh
+++ b/paludis/repositories/cran/cran_repository.hh
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2006 Danny van Dyk
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -134,7 +134,7 @@ namespace paludis
/* RepositorySyncableInterface */
- virtual bool sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const;
+ virtual bool sync(const std::tr1::shared_ptr<OutputManager> & output_deviant) const;
/* Repository */
diff --git a/paludis/repositories/e/check_fetched_files_visitor.cc b/paludis/repositories/e/check_fetched_files_visitor.cc
index 2a78c95..6194391 100644
--- a/paludis/repositories/e/check_fetched_files_visitor.cc
+++ b/paludis/repositories/e/check_fetched_files_visitor.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -31,7 +31,6 @@
#include <paludis/util/system.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/fs_entry.hh>
-#include <paludis/util/log.hh>
#include <paludis/util/join.hh>
#include <paludis/util/save.hh>
#include <paludis/util/stringify.hh>
@@ -40,13 +39,12 @@
#include <paludis/util/sha256.hh>
#include <paludis/util/md5.hh>
#include <paludis/util/make_named_values.hh>
-#include <paludis/util/output_deviator.hh>
+#include <paludis/util/output_manager.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/indirect_iterator.hh>
#include <paludis/util/accept_visitor.hh>
#include <algorithm>
-#include <iostream>
#include <fstream>
#include <list>
#include <set>
@@ -72,8 +70,7 @@ namespace paludis
const std::tr1::shared_ptr<Manifest2Reader> m2r;
const UseManifest use_manifest;
- const std::tr1::shared_ptr<OutputDeviant> maybe_output_deviant;
- std::ostream * out;
+ const std::tr1::shared_ptr<OutputManager> output_manager;
Implementation(
const Environment * const e,
@@ -83,7 +80,7 @@ namespace paludis
const bool n,
const FSEntry & m2,
const UseManifest um,
- const std::tr1::shared_ptr<OutputDeviant> & md,
+ const std::tr1::shared_ptr<OutputManager> & md,
const bool x) :
env(e),
id(i),
@@ -95,8 +92,7 @@ namespace paludis
in_nofetch(n),
m2r(new Manifest2Reader(m2)),
use_manifest(um),
- maybe_output_deviant(md),
- out(md ? maybe_output_deviant->stdout_stream() : &std::cout)
+ output_manager(md)
{
}
};
@@ -110,7 +106,7 @@ CheckFetchedFilesVisitor::CheckFetchedFilesVisitor(
const bool n,
const FSEntry & m2,
const UseManifest um,
- const std::tr1::shared_ptr<OutputDeviant> & md,
+ const std::tr1::shared_ptr<OutputManager> & md,
const bool x) :
PrivateImplementationPattern<CheckFetchedFilesVisitor>(new Implementation<CheckFetchedFilesVisitor>(e, i, d, c, n, m2, um, md, x))
{
@@ -191,7 +187,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
{
case manifest_use:
case manifest_ignore:
- Log::get_instance()->message("e.manifest.empty", ll_debug, lc_context) << "Empty or non-existent Manifest file";
+ _imp->output_manager->log_message("e.manifest.empty", ll_debug, lc_context) << "Empty or non-existent Manifest file";
return true;
case manifest_require:
@@ -219,14 +215,14 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
continue;
found = true;
- Log::get_instance()->message("e.manifest.size", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.manifest.size", ll_debug, lc_context)
<< "Actual size = " << distfile.file_size()
<< "; Manifest file size = " << m->size();
if (distfile.file_size() != m->size())
{
- Log::get_instance()->message("e.manifest.no_size", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.manifest.no_size", ll_debug, lc_context)
<< "Malformed Manifest: no file size found";
- *_imp->out << "incorrect size";
+ _imp->output_manager->stdout_stream() << "incorrect size";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Incorrect file size"),
@@ -239,7 +235,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
std::ifstream file_stream(stringify(distfile).c_str());
if (! file_stream)
{
- *_imp->out << "unreadable file";
+ _imp->output_manager->stdout_stream() << "unreadable file";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Unreadable file"),
@@ -254,9 +250,9 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
RMD160 rmd160sum(file_stream);
if (rmd160sum.hexsum() != m->rmd160())
{
- Log::get_instance()->message("e.manifest.rmd160.failure", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.manifest.rmd160.failure", ll_debug, lc_context)
<< "Malformed Manifest: failed RMD160 checksum";
- *_imp->out << "failed RMD160";
+ _imp->output_manager->stdout_stream() << "failed RMD160";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Failed RMD160 checksum"),
@@ -265,7 +261,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
));
return false;
}
- Log::get_instance()->message("e.manifest.rmd160.result", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.manifest.rmd160.result", ll_debug, lc_context)
<< "Actual RMD160 = " << rmd160sum.hexsum();
file_stream.clear();
file_stream.seekg(0, std::ios::beg);
@@ -276,9 +272,9 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
SHA1 sha1sum(file_stream);
if (sha1sum.hexsum() != m->sha1())
{
- Log::get_instance()->message("e.manifest.sha1.failure", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.manifest.sha1.failure", ll_debug, lc_context)
<< "Malformed Manifest: failed SHA1 checksum";
- *_imp->out << "failed SHA1";
+ _imp->output_manager->stdout_stream() << "failed SHA1";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Failed SHA1 checksum"),
@@ -287,7 +283,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
));
return false;
}
- Log::get_instance()->message("e.manifest.sha1.result", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.manifest.sha1.result", ll_debug, lc_context)
<< "Actual SHA1 = " << sha1sum.hexsum();
file_stream.clear();
file_stream.seekg(0, std::ios::beg);
@@ -298,9 +294,9 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
SHA256 sha256sum(file_stream);
if (sha256sum.hexsum() != m->sha256())
{
- Log::get_instance()->message("e.manifest.sha256.failure", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.manifest.sha256.failure", ll_debug, lc_context)
<< "Malformed Manifest: failed SHA256 checksum";
- *_imp->out << "failed SHA256";
+ _imp->output_manager->stdout_stream() << "failed SHA256";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Failed SHA256 checksum"),
@@ -309,7 +305,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
));
return false;
}
- Log::get_instance()->message("e.manifest.sha256.result", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.manifest.sha256.result", ll_debug, lc_context)
<< "Actual SHA256 = " << sha256sum.hexsum();
file_stream.clear();
file_stream.seekg(0, std::ios::beg);
@@ -320,9 +316,9 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
MD5 md5sum(file_stream);
if (md5sum.hexsum() != m->md5())
{
- Log::get_instance()->message("e.manifest.md5.failure", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.manifest.md5.failure", ll_debug, lc_context)
<< "Malformed Manifest: failed MD5 checksum";
- *_imp->out << "failed MD5";
+ _imp->output_manager->stdout_stream() << "failed MD5";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Failed MD5 checksum"),
@@ -331,14 +327,14 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
));
return false;
}
- Log::get_instance()->message("e.manifest.md5.result", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.manifest.md5.result", ll_debug, lc_context)
<< "Actual MD5 = " << md5sum.hexsum();
}
}
if (! found)
{
- *_imp->out << "not in Manifest";
+ _imp->output_manager->stdout_stream() << "not in Manifest";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Not in Manifest"),
@@ -358,13 +354,13 @@ CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableUR
if (_imp->done.end() != _imp->done.find(node.spec()->filename()))
{
- Log::get_instance()->message("e.check_fetched_files.already_checked", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.check_fetched_files.already_checked", ll_debug, lc_context)
<< "Already checked '" << node.spec()->filename() << "'";
return;
}
_imp->done.insert(node.spec()->filename());
- *_imp->out << "Checking '" << node.spec()->filename() << "'... " << std::flush;
+ _imp->output_manager->stdout_stream() << "Checking '" << node.spec()->filename() << "'... " << std::flush;
if (! (_imp->distdir / node.spec()->filename()).is_regular_file())
{
@@ -372,9 +368,9 @@ CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableUR
{
if (! _imp->exclude_unmirrorable)
{
- Log::get_instance()->message("e.check_fetched_files.requires_manual", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.check_fetched_files.requires_manual", ll_debug, lc_context)
<< "Manual fetch required for '" << node.spec()->filename() << "'";
- *_imp->out << "requires manual fetch";
+ _imp->output_manager->stdout_stream() << "requires manual fetch";
_imp->need_nofetch = true;
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
@@ -386,9 +382,9 @@ CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableUR
}
else
{
- Log::get_instance()->message("e.check_fetched_files.does_not_exist", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.check_fetched_files.does_not_exist", ll_debug, lc_context)
<< "Automatic fetch failed for '" << node.spec()->filename() << "'";
- *_imp->out << "does not exist";
+ _imp->output_manager->stdout_stream() << "does not exist";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(true),
value_for<n::failed_integrity_checks>(""),
@@ -399,8 +395,8 @@ CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableUR
}
else if (0 == (_imp->distdir / node.spec()->filename()).file_size())
{
- Log::get_instance()->message("e.check_fetched_files.empty", ll_debug, lc_context) << "Empty file for '" << node.spec()->filename() << "'";
- *_imp->out << "empty file";
+ _imp->output_manager->log_message("e.check_fetched_files.empty", ll_debug, lc_context) << "Empty file for '" << node.spec()->filename() << "'";
+ _imp->output_manager->stdout_stream() << "empty file";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("SIZE (empty file)"),
@@ -410,16 +406,16 @@ CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableUR
}
else if (! check_distfile_manifest(_imp->distdir / node.spec()->filename()))
{
- Log::get_instance()->message("e.check_fetched_files.failure", ll_debug, lc_context)
+ _imp->output_manager->log_message("e.check_fetched_files.failure", ll_debug, lc_context)
<< "Manifest check failed for '" << node.spec()->filename() << "'";
}
else
{
- Log::get_instance()->message("e.check_fetched_files.success", ll_debug, lc_context) << "Success for '" << node.spec()->filename() << "'";
- *_imp->out << "ok";
+ _imp->output_manager->log_message("e.check_fetched_files.success", ll_debug, lc_context) << "Success for '" << node.spec()->filename() << "'";
+ _imp->output_manager->stdout_stream() << "ok";
}
- *_imp->out << std::endl;
+ _imp->output_manager->stdout_stream() << std::endl;
}
const std::tr1::shared_ptr<const Sequence<FetchActionFailure> >
diff --git a/paludis/repositories/e/check_fetched_files_visitor.hh b/paludis/repositories/e/check_fetched_files_visitor.hh
index c2215aa..1e0707a 100644
--- a/paludis/repositories/e/check_fetched_files_visitor.hh
+++ b/paludis/repositories/e/check_fetched_files_visitor.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -24,7 +24,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/util/output_deviator-fwd.hh>
+#include <paludis/util/output_manager-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
#include <paludis/spec_tree.hh>
#include <paludis/package_id-fwd.hh>
@@ -51,7 +51,7 @@ namespace paludis
const bool fetch_restrict,
const FSEntry & m2,
const UseManifest um,
- const std::tr1::shared_ptr<OutputDeviant> & maybe_output_deviant,
+ const std::tr1::shared_ptr<OutputManager> & output_manager,
const bool exclude_unmirrorable);
~CheckFetchedFilesVisitor();
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 226d5a7..c4ecb0e 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -723,7 +723,7 @@ ERepository::sets_list() const
}
bool
-ERepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const
+ERepository::sync(const std::tr1::shared_ptr<OutputManager> & output_manager) const
{
Context context("When syncing repository '" + stringify(name()) + "':");
@@ -745,8 +745,7 @@ ERepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_devia
SyncOptions opts(make_named_values<SyncOptions>(
value_for<n::filter_file>(_imp->layout->sync_filter_file()),
value_for<n::options>(_imp->params.sync_options()),
- value_for<n::output_deviant>(output_deviant),
- value_for<n::output_prefix>("sync " + stringify(name()) + "> ")
+ value_for<n::output_manager>(output_manager)
));
try
{
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index 2308664..3d81f92 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -133,7 +133,7 @@ namespace paludis
/* RepositorySyncableInterface */
- virtual bool sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const;
+ virtual bool sync(const std::tr1::shared_ptr<OutputManager> &) const;
/* RepositoryEnvironmentVariableInterface */
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 72cae77..f4b0b4a 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -32,6 +32,7 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
@@ -922,7 +923,7 @@ namespace test_cases
FetchAction action(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(false),
value_for<n::fetch_unneeded>(false),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::safe_resume>(true)
));
@@ -1027,7 +1028,7 @@ namespace test_cases
FetchAction action(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(false),
value_for<n::fetch_unneeded>(false),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::safe_resume>(true)
));
@@ -1099,6 +1100,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1354,6 +1356,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1448,6 +1451,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1572,6 +1576,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1774,6 +1779,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -2356,6 +2362,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/paludis/repositories/e/e_repository_TEST_ever.cc b/paludis/repositories/e/e_repository_TEST_ever.cc
index bf51591..6418889 100644
--- a/paludis/repositories/e/e_repository_TEST_ever.cc
+++ b/paludis/repositories/e/e_repository_TEST_ever.cc
@@ -32,6 +32,8 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/output_manager.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
@@ -139,6 +141,7 @@ namespace
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 245232a..77b1180 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -40,7 +40,7 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/util/cookie.hh>
-#include <paludis/util/output_deviator.hh>
+#include <paludis/util/output_manager.hh>
#include <paludis/about.hh>
#include <paludis/environment.hh>
@@ -675,10 +675,9 @@ EbuildNoFetchCommand::extend_command(const Command & cmd)
j(fetch_params.expand_vars()->end()) ; i != j ; ++i)
result.with_setenv(i->first, i->second);
- if (fetch_params.maybe_output_deviant())
- result
- .with_captured_stderr_stream(fetch_params.maybe_output_deviant()->stderr_stream())
- .with_captured_stdout_stream(fetch_params.maybe_output_deviant()->stdout_stream());
+ result
+ .with_captured_stderr_stream(&fetch_params.output_manager()->stderr_stream())
+ .with_captured_stdout_stream(&fetch_params.output_manager()->stdout_stream());
return result;
}
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index 2e4613b..688148d 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -65,9 +65,9 @@ namespace paludis
struct info_vars;
struct load_environment;
struct loadsaveenv_dir;
- struct maybe_output_deviant;
struct merger_options;
struct output_directory;
+ struct output_manager;
struct package_id;
struct portdir;
struct profiles;
@@ -124,7 +124,7 @@ namespace paludis
NamedValue<n::a, std::string> a;
NamedValue<n::aa, std::string> aa;
NamedValue<n::expand_vars, std::tr1::shared_ptr<const Map<std::string, std::string> > > expand_vars;
- NamedValue<n::maybe_output_deviant, std::tr1::shared_ptr<OutputDeviant> > maybe_output_deviant;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
NamedValue<n::profiles, std::tr1::shared_ptr<const FSEntrySequence> > profiles;
NamedValue<n::root, std::string> root;
NamedValue<n::use, std::string> use;
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index 3b6bd4a..b1e3522 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -436,13 +436,13 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
stringify(_imp->e_repository->name()));
FetchVisitor f(_imp->params.environment(), id, *id->eapi(),
_imp->e_repository->params().distdir(), o.fetch_unneeded(), fetch_userpriv_ok, mirrors_name,
- id->fetches_key()->initial_label(), o.safe_resume(), o.maybe_output_deviant());
+ id->fetches_key()->initial_label(), o.safe_resume(), o.output_manager());
id->fetches_key()->value()->root()->accept(f);
CheckFetchedFilesVisitor c(_imp->environment, id, _imp->e_repository->params().distdir(),
o.fetch_unneeded(), fetch_restrict,
((_imp->e_repository->layout()->package_directory(id->name())) / "Manifest"),
_imp->e_repository->params().use_manifest(),
- o.maybe_output_deviant(), o.exclude_unmirrorable());
+ o.output_manager(), o.exclude_unmirrorable());
id->fetches_key()->value()->root()->accept(c);
if (c.need_nofetch())
@@ -483,7 +483,7 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
value_for<n::a>(archives),
value_for<n::aa>(all_archives),
value_for<n::expand_vars>(expand_vars),
- value_for<n::maybe_output_deviant>(o.maybe_output_deviant()),
+ value_for<n::output_manager>(o.output_manager()),
value_for<n::profiles>(_imp->params.profiles()),
value_for<n::root>("/"),
value_for<n::use>(use),
diff --git a/paludis/repositories/e/exndbam_repository_TEST.cc b/paludis/repositories/e/exndbam_repository_TEST.cc
index 1a20613..f5ea42e 100644
--- a/paludis/repositories/e/exndbam_repository_TEST.cc
+++ b/paludis/repositories/e/exndbam_repository_TEST.cc
@@ -25,6 +25,8 @@
#include <paludis/util/join.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <paludis/action.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/generator.hh>
@@ -122,6 +124,7 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(exndbam_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/paludis/repositories/e/fetch_visitor.cc b/paludis/repositories/e/fetch_visitor.cc
index 5c818af..005caff 100644
--- a/paludis/repositories/e/fetch_visitor.cc
+++ b/paludis/repositories/e/fetch_visitor.cc
@@ -35,7 +35,7 @@
#include <paludis/util/join.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_shared_ptr.hh>
-#include <paludis/util/output_deviator.hh>
+#include <paludis/util/output_manager.hh>
#include <iostream>
#include <list>
@@ -56,7 +56,7 @@ namespace paludis
const std::string mirrors_name;
std::tr1::shared_ptr<const URILabel> default_label;
const bool safe_resume;
- const std::tr1::shared_ptr<OutputDeviant> maybe_output_deviant;
+ const std::tr1::shared_ptr<OutputManager> output_manager;
std::list<const URILabel *> labels;
@@ -70,7 +70,7 @@ namespace paludis
const std::string & m,
const std::tr1::shared_ptr<const URILabel> & n,
const bool sr,
- const std::tr1::shared_ptr<OutputDeviant> & md) :
+ const std::tr1::shared_ptr<OutputManager> & md) :
env(e),
id(i),
eapi(p),
@@ -80,7 +80,7 @@ namespace paludis
mirrors_name(m),
default_label(n),
safe_resume(sr),
- maybe_output_deviant(md)
+ output_manager(md)
{
labels.push_front(default_label.get());
}
@@ -97,7 +97,7 @@ FetchVisitor::FetchVisitor(
const std::string & m,
const std::tr1::shared_ptr<const URILabel> & n,
const bool sr,
- const std::tr1::shared_ptr<OutputDeviant> & md) :
+ const std::tr1::shared_ptr<OutputManager> & md) :
PrivateImplementationPattern<FetchVisitor>(new Implementation<FetchVisitor>(e, i, p, d, f, u, m, n, sr, md))
{
}
@@ -236,13 +236,12 @@ FetchVisitor::visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::T
cmd
.with_setenv("PALUDIS_USE_SAFE_RESUME", "yesplease");
- if (_imp->maybe_output_deviant)
- cmd
- .with_captured_stderr_stream(_imp->maybe_output_deviant->stderr_stream())
- .with_captured_stdout_stream(_imp->maybe_output_deviant->stdout_stream());
+ cmd
+ .with_captured_stderr_stream(&_imp->output_manager->stderr_stream())
+ .with_captured_stdout_stream(&_imp->output_manager->stdout_stream());
- (_imp->maybe_output_deviant ? *_imp->maybe_output_deviant->stdout_stream() : std::cout)
- << "Trying to fetch '" << i->first << "' to '" << i->second << "'..." << std::endl;
+ _imp->output_manager->stdout_stream() << "Trying to fetch '" << i->first << "' to '" <<
+ i->second << "'..." << std::endl;
if (0 != run_command(cmd))
destination.unlink();
diff --git a/paludis/repositories/e/fetch_visitor.hh b/paludis/repositories/e/fetch_visitor.hh
index 84013b2..f341657 100644
--- a/paludis/repositories/e/fetch_visitor.hh
+++ b/paludis/repositories/e/fetch_visitor.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -24,7 +24,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/util/output_deviator-fwd.hh>
+#include <paludis/util/output_manager-fwd.hh>
#include <paludis/dep_spec.hh>
#include <paludis/spec_tree-fwd.hh>
#include <paludis/package_id-fwd.hh>
@@ -50,7 +50,7 @@ namespace paludis
const std::string & mirrors_name,
const std::tr1::shared_ptr<const URILabel> & initial_label,
const bool safe_resume,
- const std::tr1::shared_ptr<OutputDeviant> & maybe_output_deviant);
+ const std::tr1::shared_ptr<OutputManager> &);
~FetchVisitor();
diff --git a/paludis/repositories/e/fetch_visitor_TEST.cc b/paludis/repositories/e/fetch_visitor_TEST.cc
index b8868cf..554fe82 100644
--- a/paludis/repositories/e/fetch_visitor_TEST.cc
+++ b/paludis/repositories/e/fetch_visitor_TEST.cc
@@ -25,6 +25,7 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <paludis/package_database.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/generator.hh>
@@ -62,7 +63,7 @@ namespace test_cases
&env, UserPackageDepSpecOptions()), MatchPackageOptions()))]->begin(),
*eapi, FSEntry("fetch_visitor_TEST_dir/out"),
false, false, "test", make_shared_ptr(new URIListedThenMirrorsLabel("listed-then-mirrors")), false,
- make_null_shared_ptr());
+ make_shared_ptr(new StandardOutputManager));
parse_fetchable_uri("file:///" + stringify(FSEntry("fetch_visitor_TEST_dir/in/input1").realpath()), &env, id, *eapi)->root()->accept(v);
TEST_CHECK(FSEntry("fetch_visitor_TEST_dir/out/input1").is_regular_file());
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index cedad9c..7da42cb 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -27,6 +27,7 @@
#include <paludis/util/options.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <paludis/generator.hh>
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
@@ -351,6 +352,7 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -467,6 +469,7 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -583,6 +586,7 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -979,6 +983,7 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1216,6 +1221,7 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1307,6 +1313,7 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/paludis/repositories/unavailable/unavailable_repository.cc b/paludis/repositories/unavailable/unavailable_repository.cc
index 37280b6..ed26457 100644
--- a/paludis/repositories/unavailable/unavailable_repository.cc
+++ b/paludis/repositories/unavailable/unavailable_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -254,7 +254,7 @@ UnavailableRepository::some_ids_might_support_action(const SupportsActionTestBas
}
bool
-UnavailableRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const
+UnavailableRepository::sync(const std::tr1::shared_ptr<OutputManager> & output_manager) const
{
Context context("When syncing repository '" + stringify(name()) + "':");
@@ -276,8 +276,7 @@ UnavailableRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & ou
SyncOptions opts(make_named_values<SyncOptions>(
value_for<n::filter_file>(FSEntry("/dev/null")),
value_for<n::options>(_imp->params.sync_options()),
- value_for<n::output_deviant>(output_deviant),
- value_for<n::output_prefix>("sync " + stringify(name()) + "> ")
+ value_for<n::output_manager>(output_manager)
));
try
{
diff --git a/paludis/repositories/unavailable/unavailable_repository.hh b/paludis/repositories/unavailable/unavailable_repository.hh
index eb40d33..68a15fb 100644
--- a/paludis/repositories/unavailable/unavailable_repository.hh
+++ b/paludis/repositories/unavailable/unavailable_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -92,7 +92,7 @@ namespace paludis
virtual void invalidate();
virtual void invalidate_masks();
- virtual bool sync(const std::tr1::shared_ptr<const OutputDeviant> &) const;
+ virtual bool sync(const std::tr1::shared_ptr<OutputManager> &) const;
///\name RepositoryFactory functions
///\{
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index d98b450..ea4176c 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -33,6 +33,7 @@
#include <paludis/util/join.hh>
#include <paludis/util/options.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <algorithm>
@@ -398,6 +399,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -453,6 +455,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -511,6 +514,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
index 46913ab..1520ac0 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
@@ -33,6 +33,7 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -230,6 +231,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -284,6 +286,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/paludis/repositories/unwritten/unwritten_repository.cc b/paludis/repositories/unwritten/unwritten_repository.cc
index 86a7170..4eed1d9 100644
--- a/paludis/repositories/unwritten/unwritten_repository.cc
+++ b/paludis/repositories/unwritten/unwritten_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -254,7 +254,7 @@ UnwrittenRepository::some_ids_might_support_action(const SupportsActionTestBase
}
bool
-UnwrittenRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const
+UnwrittenRepository::sync(const std::tr1::shared_ptr<OutputManager> & output_manager) const
{
Context context("When syncing repository '" + stringify(name()) + "':");
@@ -276,8 +276,7 @@ UnwrittenRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & outp
SyncOptions opts(make_named_values<SyncOptions>(
value_for<n::filter_file>(FSEntry("/dev/null")),
value_for<n::options>(_imp->params.sync_options()),
- value_for<n::output_deviant>(output_deviant),
- value_for<n::output_prefix>("sync " + stringify(name()) + "> ")
+ value_for<n::output_manager>(output_manager)
));
try
{
diff --git a/paludis/repositories/unwritten/unwritten_repository.hh b/paludis/repositories/unwritten/unwritten_repository.hh
index a2a3e93..f61a687 100644
--- a/paludis/repositories/unwritten/unwritten_repository.hh
+++ b/paludis/repositories/unwritten/unwritten_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -91,7 +91,7 @@ namespace paludis
virtual void invalidate();
virtual void invalidate_masks();
- virtual bool sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const;
+ virtual bool sync(const std::tr1::shared_ptr<OutputManager> & output_manager) const;
///\name RepositoryFactory functions
///\{
diff --git a/paludis/repository.hh b/paludis/repository.hh
index e225e3d..936d14c 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -33,7 +33,7 @@
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/util/options.hh>
#include <paludis/util/named_value.hh>
-#include <paludis/util/output_deviator-fwd.hh>
+#include <paludis/util/output_manager-fwd.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key-fwd.hh>
#include <paludis/metadata_key_holder.hh>
@@ -426,10 +426,9 @@ namespace paludis
/**
* Sync, if necessary.
*
- * \param output_deviant May be an empty pointer, for no deviation.
* \return True if we synced successfully, false if we skipped sync.
*/
- virtual bool sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const = 0;
+ virtual bool sync(const std::tr1::shared_ptr<OutputManager> &) const = 0;
///\}
diff --git a/paludis/syncer.cc b/paludis/syncer.cc
index 22935c8..49b8c7a 100644
--- a/paludis/syncer.cc
+++ b/paludis/syncer.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
* Copyright (c) 2006 Stephen Klimaszewski
* Copyright (c) 2007 David Leverton
*
@@ -28,7 +28,7 @@
#include <paludis/util/join.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/sequence.hh>
-#include <paludis/util/output_deviator.hh>
+#include <paludis/util/output_manager.hh>
#include <list>
using namespace paludis;
@@ -99,15 +99,9 @@ DefaultSyncer::sync(const SyncOptions & opts) const
.with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
.with_setenv("PALUDIS_SYNC_FILTER_FILE", stringify(opts.filter_file())));
- if (opts.output_deviant())
- cmd
- .with_captured_stderr_stream(opts.output_deviant()->stderr_stream())
- .with_captured_stdout_stream(opts.output_deviant()->stdout_stream());
- else if (! opts.output_prefix().empty())
- cmd
- .with_stdout_prefix(opts.output_prefix())
- .with_stderr_prefix(opts.output_prefix())
- .with_prefix_blank_lines();
+ cmd
+ .with_captured_stderr_stream(&opts.output_manager()->stderr_stream())
+ .with_captured_stdout_stream(&opts.output_manager()->stdout_stream());
if (run_command(cmd))
throw SyncFailedError(_local, _remote);
diff --git a/paludis/syncer.hh b/paludis/syncer.hh
index 2bf3a9c..98892b5 100644
--- a/paludis/syncer.hh
+++ b/paludis/syncer.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_SYNCER_HH 1
#include <paludis/util/exception.hh>
+#include <paludis/util/output_manager-fwd.hh>
#include <paludis/repository.hh>
#include <string>
@@ -43,8 +44,7 @@ namespace paludis
struct filter_file;
struct local;
struct options;
- struct output_deviant;
- struct output_prefix;
+ struct output_manager;
struct remote;
}
@@ -61,12 +61,9 @@ namespace paludis
NamedValue<n::options, std::string> options;
/**
- * May be a zero pointer.
- * \since 0.32
+ * \since 0.36
*/
- NamedValue<n::output_deviant, std::tr1::shared_ptr<const OutputDeviant> > output_deviant;
-
- NamedValue<n::output_prefix, std::string> output_prefix;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
};
/**
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 7f330fe..6fce62c 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -47,7 +47,7 @@ add(`named_value', `hh', `cc', `fwd')
add(`no_type', `hh')
add(`operators', `hh')
add(`options', `hh', `fwd', `cc', `test')
-add(`output_deviator', `hh', `fwd', `cc')
+add(`output_manager', `hh', `fwd', `cc')
add(`output_wrapper', `test', `testscript')
add(`pipe', `hh', `cc')
add(`pretty_print', `hh', `cc', `test')
@@ -64,6 +64,7 @@ add(`sha256', `hh', `cc', `test')
add(`simple_parser', `hh', `cc')
add(`simple_visitor', `hh', `cc', `fwd', `impl')
add(`simple_visitor_cast', `hh', `cc', `fwd')
+add(`standard_output_manager', `hh', `cc', `fwd')
add(`stringify', `hh', `test')
add(`strip', `hh', `cc', `test')
add(`system', `hh', `cc', `test', `testscript')
diff --git a/paludis/util/log.hh b/paludis/util/log.hh
index 605af64..4a677fb 100644
--- a/paludis/util/log.hh
+++ b/paludis/util/log.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -120,7 +120,6 @@ namespace paludis
LogLevel _log_level;
LogContext _log_context;
- LogMessageHandler(const LogMessageHandler &);
LogMessageHandler(Log * const, const std::string &, const LogLevel, const LogContext);
void operator= (const LogMessageHandler &);
@@ -130,6 +129,14 @@ namespace paludis
///\name Basic operations
///\{
+ /**
+ * Should really be an rvalue ref, use only for returning a newly
+ * constructed message.
+ *
+ * \since 0.36
+ */
+ LogMessageHandler(const LogMessageHandler &);
+
~LogMessageHandler();
///\}
diff --git a/paludis/util/output_deviator.cc b/paludis/util/output_deviator.cc
deleted file mode 100644
index ef32d05..0000000
--- a/paludis/util/output_deviator.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2008 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/output_deviator.hh>
-#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/fs_entry.hh>
-#include <paludis/util/make_shared_ptr.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/log.hh>
-#include <paludis/util/tee_output_stream.hh>
-#include <paludis/util/tail_output_stream.hh>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <ctime>
-#include <unistd.h>
-#include <iostream>
-#include <fstream>
-
-namespace paludis
-{
- template <>
- struct Implementation<OutputDeviator>
- {
- const FSEntry log_dir;
-
- Implementation(const FSEntry & l) :
- log_dir(l)
- {
- }
- };
-
- template <>
- struct Implementation<OutputDeviant>
- {
- const FSEntry file_name;
- std::tr1::shared_ptr<TeeOutputStream> tee_stream;
- std::tr1::shared_ptr<std::ofstream> f_stream;
- std::tr1::shared_ptr<TailOutputStream> tail_stream;
-
- Implementation(const FSEntry & f, const unsigned int number_of_tail_lines) :
- file_name(f),
- f_stream(new std::ofstream(stringify(file_name).c_str()))
- {
- if (! *f_stream)
- {
- Log::get_instance()->message("output_deviator.open_failed", ll_warning, lc_context) << "Cannot open '"
- << file_name << + "' for write, sending output to stdout and stderr instead";
- f_stream.reset();
- }
- else
- {
- tail_stream.reset(new TailOutputStream(number_of_tail_lines));
- tee_stream.reset(new TeeOutputStream(f_stream.get(), tail_stream.get()));
- }
- }
- };
-}
-
-OutputDeviator::OutputDeviator(const FSEntry & l) :
- PrivateImplementationPattern<OutputDeviator>(new Implementation<OutputDeviator>(l))
-{
-}
-
-OutputDeviator::~OutputDeviator()
-{
-}
-
-const std::tr1::shared_ptr<OutputDeviant>
-OutputDeviator::make_output_deviant(const std::string & n, const unsigned number_of_tail_lines)
-{
- return make_shared_ptr(new OutputDeviant(_imp->log_dir / (n + "." + stringify(std::time(0)) + ".log"), number_of_tail_lines));
-}
-
-OutputDeviant::OutputDeviant(const FSEntry & f, const unsigned int n) :
- PrivateImplementationPattern<OutputDeviant>(new Implementation<OutputDeviant>(f, n))
-{
-}
-
-OutputDeviant::~OutputDeviant()
-{
-}
-
-std::ostream *
-OutputDeviant::stdout_stream() const
-{
- if (_imp->tee_stream)
- return _imp->tee_stream.get();
- else
- return &std::cout;
-}
-
-std::ostream *
-OutputDeviant::stderr_stream() const
-{
- if (_imp->tee_stream)
- return _imp->tee_stream.get();
- else
- return &std::cerr;
-}
-
-void
-OutputDeviant::discard_log()
-{
- if (_imp->f_stream)
- if (-1 == ::unlink(stringify(_imp->file_name).c_str()))
- Log::get_instance()->message("output_deviant.unlink_failed", ll_warning, lc_context)
- << "Cannot unlink '" << _imp->file_name << "'";
-}
-
-const FSEntry
-OutputDeviant::log_file_name() const
-{
- return _imp->file_name;
-}
-
-const std::tr1::shared_ptr<const Sequence<std::string> >
-OutputDeviant::tail(const bool clear) const
-{
- if (_imp->tail_stream)
- return _imp->tail_stream->tail(clear);
- else
- return make_null_shared_ptr();
-}
-
-template class PrivateImplementationPattern<OutputDeviator>;
-template class PrivateImplementationPattern<OutputDeviant>;
-
diff --git a/paludis/util/output_deviator.hh b/paludis/util/output_deviator.hh
deleted file mode 100644
index f572e9c..0000000
--- a/paludis/util/output_deviator.hh
+++ /dev/null
@@ -1,71 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2008 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_DEVIATOR_HH
-#define PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_DEVIATOR_HH 1
-
-#include <paludis/util/output_deviator-fwd.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/util/sequence-fwd.hh>
-#include <tr1/memory>
-
-using namespace paludis;
-
-namespace paludis
-{
- class PALUDIS_VISIBLE OutputDeviator :
- private PrivateImplementationPattern<OutputDeviator>
- {
- public:
- OutputDeviator(const FSEntry & log_dir);
- ~OutputDeviator();
-
- const std::tr1::shared_ptr<OutputDeviant> make_output_deviant(
- const std::string &, const unsigned int number_of_tail_lines) PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE OutputDeviant :
- private PrivateImplementationPattern<OutputDeviant>
- {
- friend class OutputDeviator;
-
- private:
- OutputDeviant(const FSEntry &, const unsigned int);
-
- public:
- ~OutputDeviant();
-
- std::ostream * stdout_stream() const PALUDIS_ATTRIBUTE((warn_unused_result));
- std::ostream * stderr_stream() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- void discard_log();
- const FSEntry log_file_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- const std::tr1::shared_ptr<const Sequence<std::string> > tail(const bool clear) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
-#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
- extern template class PrivateImplementationPattern<OutputDeviator>;
- extern template class PrivateImplementationPattern<OutputDeviant>;
-#endif
-}
-
-#endif
diff --git a/paludis/util/output_deviator-fwd.hh b/paludis/util/output_manager-fwd.hh
index 3819c35..12928c4 100644
--- a/paludis/util/output_deviator-fwd.hh
+++ b/paludis/util/output_manager-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -17,13 +17,12 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_DEVIATOR_FWD_HH
-#define PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_DEVIATOR_FWD_HH 1
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_MANAGER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_MANAGER_FWD_HH 1
namespace paludis
{
- class OutputDeviator;
- class OutputDeviant;
+ class OutputManager;
}
#endif
diff --git a/paludis/util/output_manager.cc b/paludis/util/output_manager.cc
new file mode 100644
index 0000000..7fe0767
--- /dev/null
+++ b/paludis/util/output_manager.cc
@@ -0,0 +1,27 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/util/output_manager.hh>
+
+using namespace paludis;
+
+OutputManager::~OutputManager()
+{
+}
+
diff --git a/paludis/util/output_manager.hh b/paludis/util/output_manager.hh
new file mode 100644
index 0000000..35a87e6
--- /dev/null
+++ b/paludis/util/output_manager.hh
@@ -0,0 +1,43 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_MANAGER_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_MANAGER_HH 1
+
+#include <paludis/util/output_manager-fwd.hh>
+#include <paludis/util/log.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE OutputManager :
+ private InstantiationPolicy<OutputManager, instantiation_method::NonCopyableTag>
+ {
+ public:
+ virtual ~OutputManager() = 0;
+
+ virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual LogMessageHandler log_message(const std::string & id, const LogLevel, const LogContext)
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+}
+
+#endif
diff --git a/paludis/util/standard_output_manager-fwd.hh b/paludis/util/standard_output_manager-fwd.hh
new file mode 100644
index 0000000..4d6a2db
--- /dev/null
+++ b/paludis/util/standard_output_manager-fwd.hh
@@ -0,0 +1,28 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_STANDARD_OUTPUT_MANAGER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_STANDARD_OUTPUT_MANAGER_FWD_HH 1
+
+namespace paludis
+{
+ class StandardOutputManager;
+}
+
+#endif
diff --git a/paludis/util/standard_output_manager.cc b/paludis/util/standard_output_manager.cc
new file mode 100644
index 0000000..49d34d7
--- /dev/null
+++ b/paludis/util/standard_output_manager.cc
@@ -0,0 +1,50 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/util/standard_output_manager.hh>
+#include <iostream>
+
+using namespace paludis;
+
+StandardOutputManager::StandardOutputManager()
+{
+}
+
+StandardOutputManager::~StandardOutputManager()
+{
+}
+
+std::ostream &
+StandardOutputManager::stdout_stream()
+{
+ return std::cout;
+}
+
+std::ostream &
+StandardOutputManager::stderr_stream()
+{
+ return std::cerr;
+}
+
+LogMessageHandler
+StandardOutputManager::log_message(const std::string & id, const LogLevel l, const LogContext c)
+{
+ return Log::get_instance()->message(id, l, c);
+}
+
diff --git a/paludis/util/standard_output_manager.hh b/paludis/util/standard_output_manager.hh
new file mode 100644
index 0000000..9442ea0
--- /dev/null
+++ b/paludis/util/standard_output_manager.hh
@@ -0,0 +1,43 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_STANDARD_OUTPUT_MANAGER_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_STANDARD_OUTPUT_MANAGER_HH 1
+
+#include <paludis/util/standard_output_manager-fwd.hh>
+#include <paludis/util/output_manager.hh>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE StandardOutputManager :
+ public OutputManager
+ {
+ public:
+ StandardOutputManager();
+ ~StandardOutputManager();
+
+ virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual LogMessageHandler log_message(const std::string & id, const LogLevel, const LogContext)
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/python/action.cc b/python/action.cc
index cd5805d..bd6aa3d 100644
--- a/python/action.cc
+++ b/python/action.cc
@@ -23,6 +23,7 @@
#include <paludis/action.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <paludis/repository.hh>
#include <tr1/memory>
@@ -64,6 +65,7 @@ namespace
{
return new InstallActionOptions(make_named_values<InstallActionOptions>(
value_for<n::destination>(r),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -86,7 +88,7 @@ namespace
return new FetchActionOptions(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(exclude_unmirrorable),
value_for<n::fetch_unneeded>(fetch_unneeded),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::safe_resume>(safe_resume)
));
}
diff --git a/ruby/action.cc b/ruby/action.cc
index 8f69a19..457d428 100644
--- a/ruby/action.cc
+++ b/ruby/action.cc
@@ -22,6 +22,7 @@
#include <paludis/action.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <ruby.h>
using namespace paludis;
@@ -256,7 +257,7 @@ namespace
ptr = new FetchActionOptions(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(v_exclude_unmirrorable),
value_for<n::fetch_unneeded>(v_fetch_unneeded),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::safe_resume>(v_safe_resume)
));
@@ -515,6 +516,7 @@ namespace
ptr = new InstallActionOptions(make_named_values<InstallActionOptions>(
value_for<n::destination>(v_destination),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/src/clients/accerso/accerso.cc b/src/clients/accerso/accerso.cc
index e86cbfe..82142f5 100644
--- a/src/clients/accerso/accerso.cc
+++ b/src/clients/accerso/accerso.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -31,6 +31,7 @@
#include <paludis/util/map.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
#include <paludis/selection.hh>
#include <paludis/generator.hh>
@@ -139,7 +140,7 @@ main(int argc, char *argv[])
FetchAction a(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(true),
value_for<n::fetch_unneeded>(true),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::safe_resume>(true)
));
if ((*i)->supports_action(SupportsActionTest<FetchAction>()))
diff --git a/src/clients/appareo/appareo.cc b/src/clients/appareo/appareo.cc
index dc12af0..1b0f022 100644
--- a/src/clients/appareo/appareo.cc
+++ b/src/clients/appareo/appareo.cc
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2009 Kim Højgaard-Hansen
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -32,6 +32,7 @@
#include <paludis/util/map.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/standard_output_manager.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
#include <paludis/selection.hh>
#include <paludis/generator.hh>
@@ -99,7 +100,7 @@ namespace
FetchAction a(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(false),
value_for<n::fetch_unneeded>(true),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::safe_resume>(true)
));
(*i)->perform_action(a);
diff --git a/src/clients/cave/cmd_sync.cc b/src/clients/cave/cmd_sync.cc
index 9227623..1a91a93 100644
--- a/src/clients/cave/cmd_sync.cc
+++ b/src/clients/cave/cmd_sync.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -25,11 +25,11 @@
#include <paludis/package_database.hh>
#include <paludis/util/action_queue.hh>
#include <paludis/util/mutex.hh>
-#include <paludis/util/output_deviator.hh>
#include <paludis/util/named_value.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/condition_variable.hh>
#include <paludis/util/thread.hh>
+#include <paludis/util/output_manager.hh>
#include <paludis/repository.hh>
#include <paludis/environment.hh>
#include <paludis/hook.hh>
@@ -50,7 +50,7 @@ namespace paludis
{
namespace n
{
- struct output_deviant;
+ struct output_manager;
struct success;
struct summary;
}
@@ -58,6 +58,43 @@ namespace paludis
namespace
{
+ struct TailAndLogOutputManager :
+ OutputManager
+ {
+ TailAndLogOutputManager(const std::string &)
+ {
+ }
+
+ virtual std::ostream & stdout_stream()
+ {
+ return std::cout;
+ }
+
+ virtual std::ostream & stderr_stream()
+ {
+ return std::cerr;
+ }
+
+ virtual LogMessageHandler log_message(const std::string & id, const LogLevel l, const LogContext c)
+ {
+ return Log::get_instance()->message(id, l, c);
+ }
+
+ std::tr1::shared_ptr<const Sequence<std::string> > tail(const bool) const
+ {
+ return make_shared_ptr(new Sequence<std::string>);
+ }
+
+ void discard_log()
+ {
+ }
+
+ const FSEntry log_file_name() const
+ {
+ return FSEntry("/dev/null");
+ }
+ };
+
struct SyncCommandLine :
CaveCommandCommandLine
{
@@ -85,7 +122,7 @@ namespace
struct Message
{
- NamedValue<n::output_deviant, std::tr1::shared_ptr<OutputDeviant> > output_deviant;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<TailAndLogOutputManager> > output_manager;
NamedValue<n::success, bool> success;
NamedValue<n::summary, std::string> summary;
};
@@ -94,7 +131,7 @@ namespace
void do_one_sync_notifier(const RepositoryName & r, Mutex & notifier_mutex,
Mutex & count_mutex, ConditionVariable & notifier_condition, int & np, int & na, int & nd,
- bool & finished, OutputDeviant & output_deviant)
+ bool & finished, TailAndLogOutputManager & output_manager)
{
bool first(true);
while (true)
@@ -107,7 +144,7 @@ namespace
if (! first)
{
cout << format_general_spad(f::sync_repo_active(), stringify(r), np, na, nd);
- std::tr1::shared_ptr<const Sequence<std::string> > tail(output_deviant.tail(true));
+ std::tr1::shared_ptr<const Sequence<std::string> > tail(output_manager.tail(true));
if (tail && tail->begin() != tail->end())
{
for (Sequence<std::string>::ConstIterator t(tail->begin()), t_end(tail->end()) ;
@@ -124,15 +161,10 @@ namespace
}
void do_one_sync(const std::tr1::shared_ptr<Environment> & env, const RepositoryName & r, Mutex & mutex,
- Messages & messages, int & retcode, int & np, int & na, int & nd,
- OutputDeviator & output_deviator)
+ Messages & messages, int & retcode, int & np, int & na, int & nd)
{
- std::tr1::shared_ptr<OutputDeviant> output_deviant;
-
- {
- Lock lock(mutex);
- output_deviant = output_deviator.make_output_deviant("sync-" + stringify(r), 10);
- }
+ std::tr1::shared_ptr<TailAndLogOutputManager> output_manager(
+ new TailAndLogOutputManager("sync-" + stringify(r)));
bool done_decrement(false);
@@ -166,11 +198,11 @@ namespace
std::tr1::ref(notifier_mutex), std::tr1::ref(mutex),
std::tr1::ref(notifier_condition),
std::tr1::ref(np), std::tr1::ref(na), std::tr1::ref(nd),
- std::tr1::ref(finished), std::tr1::ref(*output_deviant)));
+ std::tr1::ref(finished), std::tr1::ref(*output_manager)));
try
{
- result = repo->syncable_interface()->sync(output_deviant);
+ result = repo->syncable_interface()->sync(output_manager);
{
Lock lock(mutex);
@@ -209,7 +241,7 @@ namespace
{
Lock lock(mutex);
messages.insert(make_pair(stringify(r), make_named_values<Message>(
- value_for<n::output_deviant>(output_deviant),
+ value_for<n::output_manager>(output_manager),
value_for<n::success>(true),
value_for<n::summary>("success")
)));
@@ -219,7 +251,7 @@ namespace
{
Lock lock(mutex);
messages.insert(make_pair(stringify(r), make_named_values<Message>(
- value_for<n::output_deviant>(output_deviant),
+ value_for<n::output_manager>(output_manager),
value_for<n::success>(true),
value_for<n::summary>("no syncing required")
)));
@@ -239,13 +271,13 @@ namespace
retcode |= 1;
messages.insert(make_pair(stringify(r), make_named_values<Message>(
- value_for<n::output_deviant>(output_deviant),
+ value_for<n::output_manager>(output_manager),
value_for<n::success>(false),
value_for<n::summary>(e.message() + " (" + e.what() + ")")
)));
cout << format_general_spad(f::sync_repo_done_failure(), stringify(r), np, na, nd);
- std::tr1::shared_ptr<const Sequence<std::string> > tail(output_deviant->tail(true));
+ std::tr1::shared_ptr<const Sequence<std::string> > tail(output_manager->tail(true));
if (tail && tail->begin() != tail->end())
{
for (Sequence<std::string>::ConstIterator t(tail->begin()), t_end(tail->end()) ;
@@ -281,8 +313,6 @@ SyncCommand::run(
int retcode(0);
Messages messages;
- OutputDeviator output_deviator(FSEntry("/tmp"));
-
std::set<RepositoryName, RepositoryNameComparator> repos;
if (cmdline.begin_parameters() != cmdline.end_parameters())
for (SyncCommandLine::ParametersConstIterator p(cmdline.begin_parameters()), p_end(cmdline.end_parameters()) ;
@@ -313,7 +343,7 @@ SyncCommand::run(
r != r_end ; ++r)
actions.enqueue(std::tr1::bind(&do_one_sync, env, *r, std::tr1::ref(mutex),
std::tr1::ref(messages), std::tr1::ref(retcode), std::tr1::ref(pending),
- std::tr1::ref(active), std::tr1::ref(done), std::tr1::ref(output_deviator)));
+ std::tr1::ref(active), std::tr1::ref(done)));
}
if (0 != env->perform_hook(Hook("sync_all_post")
@@ -329,12 +359,12 @@ SyncCommand::run(
if (m->second.success())
{
cout << format_general_kv(f::sync_message_success(), m->first, m->second.summary());
- m->second.output_deviant()->discard_log();
+ m->second.output_manager()->discard_log();
}
else
{
cout << format_general_kv(f::sync_message_failure(), m->first, m->second.summary());
- cout << format_general_kv(f::sync_message_failure_message(), "Log file", stringify(m->second.output_deviant()->log_file_name()));
+ cout << format_general_kv(f::sync_message_failure_message(), "Log file", stringify(m->second.output_manager()->log_file_name()));
}
}
cout << endl;