aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-13 00:37:41 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-13 00:38:04 +0000
commit2d61d63874ad7009f1f9075c26024f1875cd85e0 (patch)
treedaddc4ce80f03ee4b23ea3983284b4acefac74c6
parent42dc8dd1f2e1f0bf33cbb0ea5dcac0ed20dfa083 (diff)
downloadpaludis-2d61d63874ad7009f1f9075c26024f1875cd85e0.tar.gz
paludis-2d61d63874ad7009f1f9075c26024f1875cd85e0.tar.xz
Show where we saved logs
-rw-r--r--paludis/environments/paludis/output_managers/keep_stdout_as_messages.conf2
-rw-r--r--paludis/environments/paludis/output_managers/logged_only.conf2
-rw-r--r--paludis/file_output_manager.cc89
-rw-r--r--paludis/file_output_manager.hh4
4 files changed, 79 insertions, 18 deletions
diff --git a/paludis/environments/paludis/output_managers/keep_stdout_as_messages.conf b/paludis/environments/paludis/output_managers/keep_stdout_as_messages.conf
index 9888709..6e45680 100644
--- a/paludis/environments/paludis/output_managers/keep_stdout_as_messages.conf
+++ b/paludis/environments/paludis/output_managers/keep_stdout_as_messages.conf
@@ -5,4 +5,6 @@ stdout = /var/log/paludis/%{time}-%{action}-%{id}.messages
stderr = ${stdout}
keep_on_success = true
keep_on_empty = false
+summary_output_manager = standard
+summary_output_stdout_message = Messages log: ${stdout}
diff --git a/paludis/environments/paludis/output_managers/logged_only.conf b/paludis/environments/paludis/output_managers/logged_only.conf
index b41f5ab..5448b4c 100644
--- a/paludis/environments/paludis/output_managers/logged_only.conf
+++ b/paludis/environments/paludis/output_managers/logged_only.conf
@@ -6,4 +6,6 @@ stdout = /var/log/paludis/%{time}-%{action}-%{id}.out
stderr = ${stdout}
keep_on_success = false
keep_on_empty = true
+summary_output_manager = standard
+summary_output_stdout_message = Output log: ${stdout}
diff --git a/paludis/file_output_manager.cc b/paludis/file_output_manager.cc
index 1dfe40d..8e9feca 100644
--- a/paludis/file_output_manager.cc
+++ b/paludis/file_output_manager.cc
@@ -39,18 +39,32 @@ namespace paludis
std::tr1::shared_ptr<SafeOFStream> stdout_stream;
std::tr1::shared_ptr<SafeOFStream> stderr_stream;
const bool keep_on_success, keep_on_empty;
+ const std::tr1::shared_ptr<OutputManager> summary_output_manager;
+ const std::string summary_output_stdout_message;
+ const std::string summary_output_stderr_message;
+
+ bool succeeded, unlinked_stdout, unlinked_stderr;
Implementation(
const FSEntry & o,
const FSEntry & e,
const bool k,
- const bool l
+ const bool l,
+ const std::tr1::shared_ptr<OutputManager> & m,
+ const std::string & s,
+ const std::string & t
) :
stdout_file(o),
stderr_file(e),
stdout_stream(new SafeOFStream(o)),
keep_on_success(k),
- keep_on_empty(l)
+ keep_on_empty(l),
+ summary_output_manager(m),
+ summary_output_stdout_message(s),
+ summary_output_stderr_message(t),
+ succeeded(false),
+ unlinked_stdout(false),
+ unlinked_stderr(false)
{
if (o == e)
stderr_stream = stdout_stream;
@@ -60,8 +74,9 @@ namespace paludis
};
}
-FileOutputManager::FileOutputManager(const FSEntry & o, const FSEntry & e, const bool k, const bool l) :
- PrivateImplementationPattern<FileOutputManager>(new Implementation<FileOutputManager>(o, e, k, l))
+FileOutputManager::FileOutputManager(const FSEntry & o, const FSEntry & e, const bool k, const bool l,
+ const std::tr1::shared_ptr<OutputManager> & m, const std::string & s, const std::string & t) :
+ PrivateImplementationPattern<FileOutputManager>(new Implementation<FileOutputManager>(o, e, k, l, m, s, t))
{
}
@@ -74,12 +89,36 @@ FileOutputManager::~FileOutputManager()
FSEntry stdout_file_now(stringify(_imp->stdout_file)), stderr_file_now(stringify(_imp->stderr_file));
if (stdout_file_now.exists() && 0 == stdout_file_now.file_size())
+ {
_imp->stdout_file.unlink();
+ _imp->unlinked_stdout = true;
+ }
if (stdout_file_now != stderr_file_now)
{
if (stderr_file_now.exists() && 0 == stderr_file_now.file_size())
+ {
_imp->stderr_file.unlink();
+ _imp->unlinked_stderr = true;
+ }
+ }
+ }
+
+ if (_imp->summary_output_manager)
+ {
+ if ((! _imp->unlinked_stdout) && (! _imp->summary_output_stdout_message.empty()))
+ {
+ _imp->summary_output_manager->stdout_stream()
+ << _imp->summary_output_stdout_message
+ << std::endl;
+ }
+
+ if (_imp->stdout_file != _imp->stderr_file)
+ {
+ if ((! _imp->unlinked_stderr) && (! _imp->summary_output_stderr_message.empty()))
+ _imp->summary_output_manager->stdout_stream()
+ << _imp->summary_output_stderr_message
+ << std::endl;
}
}
}
@@ -99,10 +138,14 @@ FileOutputManager::stderr_stream()
void
FileOutputManager::succeeded()
{
+ _imp->succeeded = true;
+
if (! _imp->keep_on_success)
{
_imp->stdout_file.unlink();
_imp->stderr_file.unlink();
+ _imp->unlinked_stdout = true;
+ _imp->unlinked_stderr = true;
}
}
@@ -122,28 +165,40 @@ FileOutputManager::factory_managers()
const std::tr1::shared_ptr<OutputManager>
FileOutputManager::factory_create(
const OutputManagerFactory::KeyFunction & key_func,
- const OutputManagerFactory::CreateChildFunction &,
+ const OutputManagerFactory::CreateChildFunction & create_child_function,
const OutputManagerFactory::ReplaceVarsFunc & replace_vars_func)
{
- std::string o_s(key_func("stdout")), e_s(key_func("stderr")), k_s(key_func("keep_on_success")),
- l_s(key_func("keep_on_empty"));
+ std::string stdout_s(key_func("stdout")), stderr_s(key_func("stderr")),
+ keep_on_success_s(key_func("keep_on_success")), keep_on_empty_s(key_func("keep_on_empty")),
+ summary_output_manager_s(key_func("summary_output_manager")),
+ summary_output_stdout_message_s(key_func("summary_output_stdout_message")),
+ summary_output_stderr_message_s(key_func("summary_output_stderr_message"));
- if (o_s.empty())
+ if (stdout_s.empty())
throw ConfigurationError("Key 'stdout' not specified when creating a file output manager");
- o_s = replace_vars_func(o_s);
+ stdout_s = replace_vars_func(stdout_s);
- if (e_s.empty())
+ if (stderr_s.empty())
throw ConfigurationError("Key 'stderr' not specified when creating a file output manager");
- e_s = replace_vars_func(e_s);
+ stderr_s = replace_vars_func(stderr_s);
+
+ if (keep_on_success_s.empty())
+ keep_on_success_s = "true";
+
+ if (keep_on_empty_s.empty())
+ keep_on_empty_s = "true";
- if (k_s.empty())
- throw ConfigurationError("Key 'keep_on_success' not specified when creating a file output manager");
+ std::tr1::shared_ptr<OutputManager> summary_output_manager;
+ if (! summary_output_manager_s.empty())
+ summary_output_manager = create_child_function(summary_output_manager_s);
- if (l_s.empty())
- throw ConfigurationError("Key 'keep_on_empty' not specified when creating a file output manager");
+ summary_output_stdout_message_s = replace_vars_func(summary_output_stdout_message_s);
+ summary_output_stderr_message_s = replace_vars_func(summary_output_stderr_message_s);
- return make_shared_ptr(new FileOutputManager(FSEntry(o_s), FSEntry(e_s), destringify<bool>(k_s),
- destringify<bool>(l_s)));
+ return make_shared_ptr(new FileOutputManager(FSEntry(stdout_s), FSEntry(stderr_s),
+ destringify<bool>(keep_on_success_s), destringify<bool>(keep_on_empty_s),
+ summary_output_manager, summary_output_stdout_message_s,
+ summary_output_stderr_message_s));
}
template class PrivateImplementationPattern<FileOutputManager>;
diff --git a/paludis/file_output_manager.hh b/paludis/file_output_manager.hh
index fc6eea3..5009abe 100644
--- a/paludis/file_output_manager.hh
+++ b/paludis/file_output_manager.hh
@@ -37,7 +37,9 @@ namespace paludis
{
public:
FileOutputManager(const FSEntry &, const FSEntry &, const bool keep_on_success,
- const bool keep_on_empty);
+ const bool keep_on_empty, const std::tr1::shared_ptr<OutputManager> & summary_output_manager,
+ const std::string & summary_output_stdout_message,
+ const std::string & summary_output_stderr_message);
~FileOutputManager();
virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result));