diff options
Diffstat (limited to 'paludis')
-rw-r--r-- | paludis/environments/paludis/default_output.conf | 8 | ||||
-rw-r--r-- | paludis/environments/paludis/output_managers/Makefile.am | 8 | ||||
-rw-r--r-- | paludis/environments/paludis/output_managers/keep_messages.conf | 5 | ||||
-rw-r--r-- | paludis/environments/paludis/output_managers/keep_stdout_as_messages.conf | 7 | ||||
-rw-r--r-- | paludis/environments/paludis/output_managers/logged.conf | 5 | ||||
-rw-r--r-- | paludis/environments/paludis/output_managers/logged_only.conf | 4 | ||||
-rw-r--r-- | paludis/environments/paludis/output_managers/quiet.conf | 6 | ||||
-rw-r--r-- | paludis/environments/paludis/output_managers/show_messages.conf | 5 | ||||
-rw-r--r-- | paludis/files.m4 | 1 | ||||
-rw-r--r-- | paludis/messages_to_stdout_output_handler-fwd.hh | 28 | ||||
-rw-r--r-- | paludis/messages_to_stdout_output_handler.cc | 105 | ||||
-rw-r--r-- | paludis/messages_to_stdout_output_handler.hh | 63 | ||||
-rw-r--r-- | paludis/output_manager_factory.cc | 2 | ||||
-rw-r--r-- | paludis/util/discard_output_stream.cc | 40 | ||||
-rw-r--r-- | paludis/util/discard_output_stream.hh | 59 | ||||
-rw-r--r-- | paludis/util/files.m4 | 1 |
16 files changed, 341 insertions, 6 deletions
diff --git a/paludis/environments/paludis/default_output.conf b/paludis/environments/paludis/default_output.conf index 9c8cf0692..7c87df8f0 100644 --- a/paludis/environments/paludis/default_output.conf +++ b/paludis/environments/paludis/default_output.conf @@ -1 +1,9 @@ +# By default, output to stdout, keep logs of messages and keep output logs on +# failure: + type = * : logged + +# But if we're being run in the background, display only messages to stdout, and +# keep logs of messages and keep output logs on failure: + +type = * output_exclusivity = background : quiet diff --git a/paludis/environments/paludis/output_managers/Makefile.am b/paludis/environments/paludis/output_managers/Makefile.am index ed7a08050..5137a58fc 100644 --- a/paludis/environments/paludis/output_managers/Makefile.am +++ b/paludis/environments/paludis/output_managers/Makefile.am @@ -12,9 +12,13 @@ DEFS= \ shareenvpaludisdir = $(sharedir)/paludis/environments/paludis/output_managers dist_shareenvpaludis_DATA = \ - standard.conf \ + keep_messages.conf \ + keep_stdout_as_messages.conf \ logged.conf \ - logged_only.conf + logged_only.conf \ + quiet.conf \ + show_messages.conf \ + standard.conf logdir = /var/log/paludis diff --git a/paludis/environments/paludis/output_managers/keep_messages.conf b/paludis/environments/paludis/output_managers/keep_messages.conf new file mode 100644 index 000000000..927124369 --- /dev/null +++ b/paludis/environments/paludis/output_managers/keep_messages.conf @@ -0,0 +1,5 @@ +# Keep message logs + +handler = messages_to_stdout +child = keep_stdout_as_messages + diff --git a/paludis/environments/paludis/output_managers/keep_stdout_as_messages.conf b/paludis/environments/paludis/output_managers/keep_stdout_as_messages.conf new file mode 100644 index 000000000..67a2787d8 --- /dev/null +++ b/paludis/environments/paludis/output_managers/keep_stdout_as_messages.conf @@ -0,0 +1,7 @@ +# Keep message logs. For use by keep_messages; do not use directly. + +handler = file +stdout = /var/log/paludis/%{time}-%{action}-%{id}.messages +stderr = ${stdout} +keep_on_success = true + diff --git a/paludis/environments/paludis/output_managers/logged.conf b/paludis/environments/paludis/output_managers/logged.conf index 338d31bf2..bf7a5ba15 100644 --- a/paludis/environments/paludis/output_managers/logged.conf +++ b/paludis/environments/paludis/output_managers/logged.conf @@ -1,5 +1,6 @@ -# Sends output to both standard and logged_only. +# Output to stdout / stderr, keep logs of messages and keep output logs on +# failure. handler = tee -children = standard logged_only +children = standard logged_only keep_messages diff --git a/paludis/environments/paludis/output_managers/logged_only.conf b/paludis/environments/paludis/output_managers/logged_only.conf index 5884ea383..b8c8a0f63 100644 --- a/paludis/environments/paludis/output_managers/logged_only.conf +++ b/paludis/environments/paludis/output_managers/logged_only.conf @@ -1,5 +1,5 @@ -# This output handler keeps logs in /var/log/paludis/, but removes them on -# success. +# Keep logs of output only, and discard on success. Used by logged and quiet, +# but may be directly useful. handler = file stdout = /var/log/paludis/%{time}-%{action}-%{id}.out diff --git a/paludis/environments/paludis/output_managers/quiet.conf b/paludis/environments/paludis/output_managers/quiet.conf new file mode 100644 index 000000000..899812440 --- /dev/null +++ b/paludis/environments/paludis/output_managers/quiet.conf @@ -0,0 +1,6 @@ +# Messages only to stdout / stderr, keep logs of messages and keep output logs +# on failure. + +handler = tee +children = logged_only show_messages keep_messages + diff --git a/paludis/environments/paludis/output_managers/show_messages.conf b/paludis/environments/paludis/output_managers/show_messages.conf new file mode 100644 index 000000000..a6981b012 --- /dev/null +++ b/paludis/environments/paludis/output_managers/show_messages.conf @@ -0,0 +1,5 @@ +# Show messages only. + +handler = messages_to_stdout +child = standard + diff --git a/paludis/files.m4 b/paludis/files.m4 index 61a1b6978..a3492e86f 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -49,6 +49,7 @@ add(`mask', `hh', `cc', `fwd', `se') add(`match_package', `hh', `cc', `se', `fwd') add(`merger', `hh', `cc', `fwd', `se', `test', `testscript') add(`merger_entry_type', `hh', `cc', `se') +add(`messages_to_stdout_output_handler', `hh', `cc', `fwd') add(`metadata_key', `hh', `cc', `se', `fwd') add(`metadata_key_holder', `hh', `cc', `fwd') add(`name', `hh', `cc', `fwd', `test') diff --git a/paludis/messages_to_stdout_output_handler-fwd.hh b/paludis/messages_to_stdout_output_handler-fwd.hh new file mode 100644 index 000000000..9e2ec56a1 --- /dev/null +++ b/paludis/messages_to_stdout_output_handler-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_MESSAGES_TO_STDOUT_OUTPUT_HANDLER_FWD_HH +#define PALUDIS_GUARD_PALUDIS_MESSAGES_TO_STDOUT_OUTPUT_HANDLER_FWD_HH 1 + +namespace paludis +{ + struct MessagesToStdoutOutputManager; +} + +#endif diff --git a/paludis/messages_to_stdout_output_handler.cc b/paludis/messages_to_stdout_output_handler.cc new file mode 100644 index 000000000..0a833592a --- /dev/null +++ b/paludis/messages_to_stdout_output_handler.cc @@ -0,0 +1,105 @@ +/* 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/messages_to_stdout_output_handler.hh> +#include <paludis/util/private_implementation_pattern-impl.hh> +#include <paludis/util/discard_output_stream.hh> +#include <paludis/util/sequence-impl.hh> +#include <paludis/util/set.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/make_shared_ptr.hh> +#include <paludis/util/exception.hh> +#include <sstream> + +using namespace paludis; + +namespace paludis +{ + template <> + struct Implementation<MessagesToStdoutOutputManager> + { + DiscardOutputStream output_stream; + const std::tr1::shared_ptr<OutputManager> child; + + Implementation(const std::tr1::shared_ptr<OutputManager> & c) : + child(c) + { + } + }; +} + +MessagesToStdoutOutputManager::MessagesToStdoutOutputManager( + const std::tr1::shared_ptr<OutputManager> & s) : + PrivateImplementationPattern<MessagesToStdoutOutputManager>(new Implementation<MessagesToStdoutOutputManager>(s)) +{ +} + +MessagesToStdoutOutputManager::~MessagesToStdoutOutputManager() +{ +} + +std::ostream & +MessagesToStdoutOutputManager::stdout_stream() +{ + return _imp->output_stream; +} + +std::ostream & +MessagesToStdoutOutputManager::stderr_stream() +{ + return _imp->output_stream; +} + +void +MessagesToStdoutOutputManager::succeeded() +{ + _imp->child->succeeded(); +} + +void +MessagesToStdoutOutputManager::message(const MessageType t, const std::string & s) +{ + std::ostringstream m; + m << t << " " << s << std::endl; + _imp->child->stdout_stream() << m.str(); +} + +const std::tr1::shared_ptr<const Set<std::string> > +MessagesToStdoutOutputManager::factory_managers() +{ + std::tr1::shared_ptr<Set<std::string> > result(new Set<std::string>); + result->insert("messages_to_stdout"); + return result; +} + +const std::tr1::shared_ptr<OutputManager> +MessagesToStdoutOutputManager::factory_create( + const OutputManagerFactory::KeyFunction & key_func, + const OutputManagerFactory::CreateChildFunction & create_child, + const OutputManagerFactory::ReplaceVarsFunc &) +{ + std::string child(key_func("child")); + if (child.empty()) + throw ConfigurationError("No child specified for MessagesToStdoutOutputManager"); + + return make_shared_ptr(new MessagesToStdoutOutputManager(create_child(child))); +} + +template class PrivateImplementationPattern<MessagesToStdoutOutputManager>; + diff --git a/paludis/messages_to_stdout_output_handler.hh b/paludis/messages_to_stdout_output_handler.hh new file mode 100644 index 000000000..3766f9ef7 --- /dev/null +++ b/paludis/messages_to_stdout_output_handler.hh @@ -0,0 +1,63 @@ +/* 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_MESSAGES_TO_STDOUT_OUTPUT_HANDLER_HH +#define PALUDIS_GUARD_PALUDIS_MESSAGES_TO_STDOUT_OUTPUT_HANDLER_HH 1 + +#include <paludis/messages_to_stdout_output_handler-fwd.hh> +#include <paludis/output_manager.hh> +#include <paludis/output_manager_factory.hh> +#include <paludis/util/set-fwd.hh> +#include <paludis/util/private_implementation_pattern.hh> +#include <paludis/util/fs_entry-fwd.hh> +#include <tr1/memory> +#include <tr1/functional> + +namespace paludis +{ + class PALUDIS_VISIBLE MessagesToStdoutOutputManager : + private PrivateImplementationPattern<MessagesToStdoutOutputManager>, + public OutputManager + { + public: + MessagesToStdoutOutputManager(const std::tr1::shared_ptr<OutputManager> &); + ~MessagesToStdoutOutputManager(); + + virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual void succeeded(); + virtual void message(const MessageType, const std::string &); + + static const std::tr1::shared_ptr<const Set<std::string> > factory_managers() + PALUDIS_ATTRIBUTE((warn_unused_result)); + + static const std::tr1::shared_ptr<OutputManager> factory_create( + const OutputManagerFactory::KeyFunction &, + const OutputManagerFactory::CreateChildFunction &, + const OutputManagerFactory::ReplaceVarsFunc &) + PALUDIS_ATTRIBUTE((warn_unused_result)); + }; + +#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE + extern template class PrivateImplementationPattern<MessagesToStdoutOutputManager>; +#endif +} + +#endif diff --git a/paludis/output_manager_factory.cc b/paludis/output_manager_factory.cc index 1afed72a1..c5ad78133 100644 --- a/paludis/output_manager_factory.cc +++ b/paludis/output_manager_factory.cc @@ -35,6 +35,7 @@ #include <list> #include <paludis/file_output_manager.hh> +#include <paludis/messages_to_stdout_output_handler.hh> #include <paludis/standard_output_manager.hh> #include <paludis/tee_output_manager.hh> @@ -86,6 +87,7 @@ OutputManagerFactory::OutputManagerFactory() : { /* we might want to make this plugin loadable at some point */ add_manager(FileOutputManager::factory_managers(), FileOutputManager::factory_create); + add_manager(MessagesToStdoutOutputManager::factory_managers(), MessagesToStdoutOutputManager::factory_create); add_manager(StandardOutputManager::factory_managers(), StandardOutputManager::factory_create); add_manager(TeeOutputManager::factory_managers(), TeeOutputManager::factory_create); } diff --git a/paludis/util/discard_output_stream.cc b/paludis/util/discard_output_stream.cc new file mode 100644 index 000000000..7386ee771 --- /dev/null +++ b/paludis/util/discard_output_stream.cc @@ -0,0 +1,40 @@ +/* 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/discard_output_stream.hh> + +using namespace paludis; + +DiscardOutputStream::DiscardOutputStream() : + std::ostream(&buf) +{ +} + +DiscardOutputStreamBuf::int_type +DiscardOutputStreamBuf::overflow(int_type c) +{ + return c; +} + +std::streamsize +DiscardOutputStreamBuf::xsputn(const char *, std::streamsize num) +{ + return num; +} + diff --git a/paludis/util/discard_output_stream.hh b/paludis/util/discard_output_stream.hh new file mode 100644 index 000000000..a0577f83e --- /dev/null +++ b/paludis/util/discard_output_stream.hh @@ -0,0 +1,59 @@ +/* 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_DISCARD_OUTPUT_STREAM_HH +#define PALUDIS_GUARD_PALUDIS_UTIL_DISCARD_OUTPUT_STREAM_HH 1 + +#include <paludis/util/attributes.hh> +#include <ostream> + +namespace paludis +{ + class PALUDIS_VISIBLE DiscardOutputStreamBuf : + public std::streambuf + { + protected: + virtual int_type + overflow(int_type c); + + virtual std::streamsize + xsputn(const char * s, std::streamsize num); + }; + + class PALUDIS_VISIBLE DiscardOutputStreamBase + { + protected: + DiscardOutputStreamBuf buf; + }; + + class PALUDIS_VISIBLE DiscardOutputStream : + protected DiscardOutputStreamBase, + public std::ostream + { + public: + ///\name Basic operations + ///\{ + + DiscardOutputStream(); + + ///\} + }; +} + +#endif diff --git a/paludis/util/files.m4 b/paludis/util/files.m4 index b4faa42d5..23d58faf3 100644 --- a/paludis/util/files.m4 +++ b/paludis/util/files.m4 @@ -22,6 +22,7 @@ add(`damerau_levenshtein', `hh', `cc', `test') add(`destringify', `hh', `cc', `test') add(`deferred_construction_ptr', `hh', `cc', `fwd', `test') add(`dir_iterator', `hh', `cc', `fwd', `se', `test', `testscript') +add(`discard_output_stream', `hh', `cc') add(`exception', `hh', `cc') add(`fast_unique_copy', `hh', `test') add(`forward_parallel_for_each', `hh', `test') |