2008-03-23 Tollef Fog Heen <tfheen@err.no>

* main.c (main): Add logging support from NetBSD.  Thanks to Julio
       M. Merino Vidal for forwarding the patch from ages ago.
This commit is contained in:
Tollef Fog Heen 2008-03-23 20:51:50 +01:00
parent 53abbad201
commit cebb308ce4
2 changed files with 33 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2008-03-23 Tollef Fog Heen <tfheen@err.no>
* main.c (main): Add logging support from NetBSD. Thanks to Julio
M. Merino Vidal for forwarding the patch from ages ago.
2008-03-23 Stepan Kasal <skasal@redhat.com>
* pkg-config.1: Document "Requires.private" and recommend it

29
main.c
View file

@ -206,7 +206,7 @@ main (int argc, char **argv)
char **search_dirs;
char **iter;
gboolean need_newline;
FILE *log;
const char *pkgname;
Package *pkg;
@ -421,6 +421,17 @@ main (int argc, char **argv)
g_strstrip (str->str);
if (getenv("PKG_CONFIG_LOG") != NULL)
{
log = fopen (getenv ("PKG_CONFIG_LOG"), "a");
if (log == NULL)
{
fprintf (stderr, "Cannot open log file: %s\n",
getenv ("PKG_CONFIG_LOG"));
exit (1);
}
}
{
gboolean failed = FALSE;
GSList *reqs;
@ -441,6 +452,17 @@ main (int argc, char **argv)
else
req = get_package (ver->name);
if (log != NULL)
{
if (req == NULL)
fprintf (log, "%s NOT-FOUND", ver->name);
else
fprintf (log, "%s %s %s", ver->name,
comparison_to_str (ver->comparison),
(ver->version == NULL) ? "(null)" : ver->version);
fprintf (log, "\n");
}
if (req == NULL)
{
failed = TRUE;
@ -471,6 +493,11 @@ main (int argc, char **argv)
iter = g_slist_next (iter);
}
if (log != NULL)
{
fclose (log);
}
if (failed) {
return 1;
}