aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-03 17:53:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-03 17:53:30 +0000
commit0922aba3f85a1c0060d612f8dbc4503a7de17b99 (patch)
tree8f973b7a737600382d35078c9dac20808b64ff86
parent0eebaed0c7d218987e64db9551479e40fac9f659 (diff)
downloadpaludis-0922aba3f85a1c0060d612f8dbc4503a7de17b99.tar.gz
paludis-0922aba3f85a1c0060d612f8dbc4503a7de17b99.tar.xz
Add Log class. Use it.
-rw-r--r--paludis/files.m41
-rw-r--r--paludis/log.cc57
-rw-r--r--paludis/log.hh57
-rw-r--r--paludis/portage_repository.cc3
-rw-r--r--paludis/pstream.cc7
5 files changed, 120 insertions, 5 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index e6c265e..718b3a3 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -51,6 +51,7 @@ add(`join', `hh', `cc', `test')
add(`key_value_config_file', `hh', `cc', `test')
add(`keyword_name', `hh', `cc')
add(`line_config_file', `hh', `cc', `test')
+add(`log', `hh', `cc')
add(`mask_reasons', `hh', `cc')
add(`match_package', `hh', `cc')
add(`package_database', `hh', `cc', `test')
diff --git a/paludis/log.cc b/paludis/log.cc
new file mode 100644
index 0000000..c7a2bfd
--- /dev/null
+++ b/paludis/log.cc
@@ -0,0 +1,57 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * 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 "log.hh"
+#include <iostream>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<Log> :
+ InternalCounted<Implementation<Log> >
+ {
+ LogLevel log_level;
+ };
+}
+
+Log::Log() :
+ PrivateImplementationPattern<Log>(new Implementation<Log>)
+{
+ _implementation->log_level = initial_ll;
+}
+
+Log::~Log()
+{
+}
+
+void
+Log::set_log_level(const LogLevel l)
+{
+ _implementation->log_level = l;
+}
+
+void
+Log::message(const LogLevel l, const std::string & s)
+{
+ if (l >= _implementation->log_level)
+ std::cerr << s << std::endl;
+}
+
diff --git a/paludis/log.hh b/paludis/log.hh
new file mode 100644
index 0000000..7c512e2
--- /dev/null
+++ b/paludis/log.hh
@@ -0,0 +1,57 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * 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_LOG_HH
+#define PALUDIS_GUARD_PALUDIS_LOG_HH 1
+
+#include <paludis/instantiation_policy.hh>
+#include <paludis/private_implementation_pattern.hh>
+
+namespace paludis
+{
+ /**
+ * Specifies the level of a log message.
+ */
+ enum LogLevel
+ {
+ ll_debug, ///< Debug message
+ ll_warning, ///< Warning message
+ last_ll, ///< Number of items
+ initial_ll = ll_debug ///< Initial value
+ };
+
+ class Log :
+ public InstantiationPolicy<Log, instantiation_method::SingletonAtStartupTag>,
+ private PrivateImplementationPattern<Log>
+ {
+ friend class InstantiationPolicy<Log, instantiation_method::SingletonAtStartupTag>;
+
+ private:
+ Log();
+
+ public:
+ ~Log();
+
+ void set_log_level(const LogLevel);
+
+ void message(const LogLevel, const std::string &);
+ };
+}
+
+#endif
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 9723def..e3f98d6 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -584,6 +584,9 @@ PortageRepository::do_version_metadata(
result->set(vmk_provide, f.get("PROVIDE"));
result->set(vmk_eapi, f.get("EAPI"));
result->set(vmk_virtual, "");
+
+ if (p.exit_status())
+ throw InternalError(PALUDIS_HERE, "ebuild failed"); /// \todo
}
_implementation->metadata.insert(std::make_pair(std::make_pair(QualifiedPackageName(c, p), v), result));
diff --git a/paludis/pstream.cc b/paludis/pstream.cc
index f2f6311..73a449b 100644
--- a/paludis/pstream.cc
+++ b/paludis/pstream.cc
@@ -18,12 +18,10 @@
*/
#include "pstream.hh"
+#include "log.hh"
#include <errno.h>
#include <cstring>
-/// \bug VV debug log
-#include <iostream>
-
using namespace paludis;
PStreamError::PStreamError(const std::string & message) throw () :
@@ -60,8 +58,7 @@ PStreamInBuf::PStreamInBuf(const std::string & command) :
_command(command),
fd(popen(command.c_str(), "r"))
{
- /// \bug VV debug log
- std::cerr << "DEBUG: popen " << command << std::endl;
+ Log::get_instance()->message(ll_debug, "DEBUG: popen " + command);
if (0 == fd)
throw PStreamError("popen('" + _command + "', 'r') failed: " +