aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-03-08 04:40:08 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-03-08 04:40:08 +0000
commit4edc5c3d5df629d139d8b7121eef9033cc8b75a4 (patch)
tree9d5c4a51ad0ce011182dfeaf8993c9436f92518f
parentabbaadc7873e3bee76923f015ae9f5fe1f6a1f46 (diff)
downloadpaludis-4edc5c3d5df629d139d8b7121eef9033cc8b75a4.tar.gz
paludis-4edc5c3d5df629d139d8b7121eef9033cc8b75a4.tar.xz
Integrate ebuild log messages. Allow cut and tr in global scope, but display a QA warning.
-rwxr-xr-xebuild/ebuild.bash6
-rw-r--r--ebuild/echo_functions.bash40
-rw-r--r--ebuild/eclass_functions.bash2
-rw-r--r--paludis/portage_repository.cc28
-rw-r--r--paludis/util/log.cc6
-rw-r--r--paludis/util/log.hh8
6 files changed, 88 insertions, 2 deletions
diff --git a/ebuild/ebuild.bash b/ebuild/ebuild.bash
index 4276077..a052bd1 100755
--- a/ebuild/ebuild.bash
+++ b/ebuild/ebuild.bash
@@ -67,13 +67,17 @@ ebuild_load_module eclass_functions
ebuild_load_ebuild()
{
[[ -f "${1}" ]] || die "Ebuild '${1}' is not a file"
+ export EBUILD="${1}"
source ${1} || die "Error sourcing ebuild '${1}'"
[[ ${RDEPEND-unset} == "unset" ]] && RDEPEND="${DEPEND}"
}
case ${1:x} in
metadata)
- tr() { /usr/bin/tr "$@" ; }
+ for f in cut tr ; do
+ eval "export ebuild_real_${f}=\"$(which $f )\""
+ eval "${f}() { ebuild_notice qa 'global scope ${f}' ; $(which $f ) \"\$@\" ; }"
+ done
PATH="" ebuild_load_ebuild "${2}"
ebuild_load_module depend
ebuild_f_depend
diff --git a/ebuild/echo_functions.bash b/ebuild/echo_functions.bash
index 235b8e0..c8a6edf 100644
--- a/ebuild/echo_functions.bash
+++ b/ebuild/echo_functions.bash
@@ -39,4 +39,44 @@ use_enable()
fi
}
+ebuild_notice_level()
+{
+ case "$1" in
+ debug)
+ echo "1";
+ ;;
+
+ qa)
+ echo "2";
+ ;;
+
+ warning)
+ echo "3";
+ ;;
+
+ silent)
+ echo "4";
+ ;;
+
+ *)
+ echo "[WARNING.EBUILD] Bad value '$1' for qa level" 1>&2
+ echo "2";
+ ;;
+ esac
+}
+
+ebuild_notice()
+{
+ local level="$1"
+ shift
+
+ local level_num=$(ebuild_notice_level "${level}" )
+ local min_level_num=$(ebuild_notice_level "${PALUDIS_EBUILD_LOG_LEVEL}" )
+
+ if [[ "${level_num}" -ge "${min_level_num}" ]] ; then
+ local upper_level=$(echo ${level} | ${ebuild_real_tr} '[:lower:]' '[:upper:]' )
+ echo "[${upper_level}.EBUILD] $* (from ${EBUILD})" 1>&2
+ fi
+ true
+}
diff --git a/ebuild/eclass_functions.bash b/ebuild/eclass_functions.bash
index 09a4aa3..f68e263 100644
--- a/ebuild/eclass_functions.bash
+++ b/ebuild/eclass_functions.bash
@@ -38,7 +38,7 @@ EXPORT_FUNCTIONS()
*)
eval "$1() { ${ECLASS}_${e} \"\$@\" ; }"
- echo "[EBUILD QA]: $e should not be in EXPORT_FUNCTIONS for ${ECLASS}" 1>&2
+ ebuild_notice "qa" "$e should not be in EXPORT_FUNCTIONS for ${ECLASS}"
;;
esac
done
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 98713b0..9627aa3 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -527,6 +527,33 @@ PortageRepository::fetch_repo_name(const std::string & location)
return RepositoryName("x-" + modified_location);
}
+namespace
+{
+ std::string
+ log_level_string()
+ {
+ switch (Log::get_instance()->log_level())
+ {
+ case ll_qa:
+ return "qa";
+
+ case ll_warning:
+ return "warning";
+
+ case ll_debug:
+ return "debug";
+
+ case ll_silent:
+ return "silent";
+
+ case last_ll:
+ ;
+ };
+
+ throw InternalError(PALUDIS_HERE, "Bad log level");
+ }
+}
+
VersionMetadata::ConstPointer
PortageRepository::do_version_metadata(
const CategoryNamePart & c, const PackageNamePart & p, const VersionSpec & v) const
@@ -622,6 +649,7 @@ PortageRepository::do_version_metadata(
"D='/dev/null' " +
"S='/dev/null' " +
"KV='" + kernel_version() + "' " +
+ "PALUDIS_EBUILD_LOG_LEVEL='" + log_level_string() + "' " +
getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis") +
"/ebuild.bash metadata '" +
stringify(_imp->location) + "/" + stringify(c) + "/" + stringify(p) + "/" +
diff --git a/paludis/util/log.cc b/paludis/util/log.cc
index 5dd8eb3..2cdedc2 100644
--- a/paludis/util/log.cc
+++ b/paludis/util/log.cc
@@ -56,6 +56,12 @@ Log::set_log_level(const LogLevel l)
_imp->log_level = l;
}
+LogLevel
+Log::log_level() const
+{
+ return _imp->log_level;
+}
+
void
Log::message(const LogLevel l, const std::string & s)
{
diff --git a/paludis/util/log.hh b/paludis/util/log.hh
index 9bbfda1..2386822 100644
--- a/paludis/util/log.hh
+++ b/paludis/util/log.hh
@@ -32,6 +32,9 @@ namespace paludis
* Keep this in order. When deciding whether to display a message, Log
* uses message log level >= current log level, so it's important that
* least critical levels have lower numeric values.
+ *
+ * When modifying this, you will probably also want to take a look at
+ * ebuild/echo_functions.bash and the command_line source files.
*/
enum LogLevel
{
@@ -67,6 +70,11 @@ namespace paludis
void set_log_level(const LogLevel);
/**
+ * Fetch the current log level.
+ */
+ LogLevel log_level() const;
+
+ /**
* Log a message at the specified level.
*/
void message(const LogLevel, const std::string &);