diff options
author | Dan McGee <dan@archlinux.org> | 2011-06-07 16:13:58 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-06-13 19:41:16 -0500 |
commit | 52bffd2457b7ba3b6fb08d3aa959ea0b53a45dc8 (patch) | |
tree | f426280f674b10c2175bd99feba8ec0e42d7b0de /lib/libalpm/be_local.c | |
parent | e2aa952689da8763d534d1c19310eb97009f4f76 (diff) | |
download | pacman-52bffd2457b7ba3b6fb08d3aa959ea0b53a45dc8.tar.xz |
Switch all logging to use handle directly
This is the last user of our global handle object. Once again the diff
is large but the functional changes are not.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_local.c')
-rw-r--r-- | lib/libalpm/be_local.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index d7d18122..d9a76cc2 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -279,13 +279,13 @@ static int checkdbdir(pmdb_t *db) const char *path = _alpm_db_path(db); if(stat(path, &buf) != 0) { - _alpm_log(PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n", + _alpm_log(db->handle, PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n", path); if(_alpm_makepath(path) != 0) { RET_ERR(db->handle, PM_ERR_SYSTEM, -1); } } else if(!S_ISDIR(buf.st_mode)) { - _alpm_log(PM_LOG_WARNING, _("removing invalid database: %s\n"), path); + _alpm_log(db->handle, PM_LOG_WARNING, _("removing invalid database: %s\n"), path); if(unlink(path) != 0 || _alpm_makepath(path) != 0) { RET_ERR(db->handle, PM_ERR_SYSTEM, -1); } @@ -383,7 +383,7 @@ static int local_db_populate(pmdb_t *db) } /* split the db entry name */ if(_alpm_splitname(name, pkg) != 0) { - _alpm_log(PM_LOG_ERROR, _("invalid name for database entry '%s'\n"), + _alpm_log(db->handle, PM_LOG_ERROR, _("invalid name for database entry '%s'\n"), name); _alpm_pkg_free(pkg); continue; @@ -391,7 +391,7 @@ static int local_db_populate(pmdb_t *db) /* duplicated database entries are not allowed */ if(_alpm_pkghash_find(db->pkgcache, pkg->name)) { - _alpm_log(PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name); + _alpm_log(db->handle, PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name); _alpm_pkg_free(pkg); continue; } @@ -403,13 +403,13 @@ static int local_db_populate(pmdb_t *db) /* explicitly read with only 'BASE' data, accessors will handle the rest */ if(_alpm_local_db_read(db, pkg, INFRQ_BASE) == -1) { - _alpm_log(PM_LOG_ERROR, _("corrupted database entry '%s'\n"), name); + _alpm_log(db->handle, PM_LOG_ERROR, _("corrupted database entry '%s'\n"), name); _alpm_pkg_free(pkg); continue; } /* add to the collection */ - _alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", + _alpm_log(db->handle, PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", pkg->name, db->treename); db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg); count++; @@ -419,7 +419,7 @@ static int local_db_populate(pmdb_t *db) if(count > 0) { db->pkgcache->list = alpm_list_msort(db->pkgcache->list, (size_t)count, _alpm_pkg_cmp); } - _alpm_log(PM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n", + _alpm_log(db->handle, PM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n", count, db->treename); return count; @@ -448,12 +448,13 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) char *pkgpath = NULL; if(info == NULL || info->name == NULL || info->version == NULL) { - _alpm_log(PM_LOG_DEBUG, "invalid package entry provided to _alpm_local_db_read, skipping\n"); + _alpm_log(db->handle, PM_LOG_DEBUG, + "invalid package entry provided to _alpm_local_db_read, skipping\n"); return -1; } if(info->origin != PKG_FROM_LOCALDB) { - _alpm_log(PM_LOG_DEBUG, + _alpm_log(db->handle, PM_LOG_DEBUG, "request to read info for a non-local package '%s', skipping...\n", info->name); return -1; @@ -468,7 +469,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) /* already loaded all of this info, do nothing */ return 0; } - _alpm_log(PM_LOG_FUNCTION, "loading package data for %s : level=0x%x\n", + _alpm_log(db->handle, PM_LOG_FUNCTION, "loading package data for %s : level=0x%x\n", info->name, inforeq); /* clear out 'line', to be certain - and to make valgrind happy */ @@ -478,7 +479,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) if(access(pkgpath, F_OK)) { /* directory doesn't exist or can't be opened */ - _alpm_log(PM_LOG_DEBUG, "cannot find '%s-%s' in db '%s'\n", + _alpm_log(db->handle, PM_LOG_DEBUG, "cannot find '%s-%s' in db '%s'\n", info->name, info->version, db->treename); goto error; } @@ -487,7 +488,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) if(inforeq & INFRQ_DESC && !(info->infolevel & INFRQ_DESC)) { snprintf(path, PATH_MAX, "%sdesc", pkgpath); if((fp = fopen(path, "r")) == NULL) { - _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); + _alpm_log(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); goto error; } while(!feof(fp)) { @@ -500,7 +501,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) goto error; } if(strcmp(_alpm_strtrim(line), info->name) != 0) { - _alpm_log(PM_LOG_ERROR, _("%s database is inconsistent: name " + _alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: name " "mismatch on package %s\n"), db->treename, info->name); } } else if(strcmp(line, "%VERSION%") == 0) { @@ -508,7 +509,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) goto error; } if(strcmp(_alpm_strtrim(line), info->version) != 0) { - _alpm_log(PM_LOG_ERROR, _("%s database is inconsistent: version " + _alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: version " "mismatch on package %s\n"), db->treename, info->name); } } else if(strcmp(line, "%DESC%") == 0) { @@ -611,7 +612,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) if(inforeq & INFRQ_FILES && !(info->infolevel & INFRQ_FILES)) { snprintf(path, PATH_MAX, "%sfiles", pkgpath); if((fp = fopen(path, "r")) == NULL) { - _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); + _alpm_log(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); goto error; } while(fgets(line, sizeof(line), fp)) { @@ -670,7 +671,7 @@ int _alpm_local_db_prepare(pmdb_t *db, pmpkg_t *info) pkgpath = get_pkgpath(db, info); if((retval = mkdir(pkgpath, 0755)) != 0) { - _alpm_log(PM_LOG_ERROR, _("could not create directory %s: %s\n"), + _alpm_log(db->handle, PM_LOG_ERROR, _("could not create directory %s: %s\n"), pkgpath, strerror(errno)); } @@ -704,11 +705,12 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) /* DESC */ if(inforeq & INFRQ_DESC) { - _alpm_log(PM_LOG_DEBUG, "writing %s-%s DESC information back to db\n", + _alpm_log(db->handle, PM_LOG_DEBUG, "writing %s-%s DESC information back to db\n", info->name, info->version); snprintf(path, PATH_MAX, "%sdesc", pkgpath); if((fp = fopen(path, "w")) == NULL) { - _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); + _alpm_log(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), + path, strerror(errno)); retval = -1; goto cleanup; } @@ -805,11 +807,12 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) /* FILES */ if(inforeq & INFRQ_FILES) { - _alpm_log(PM_LOG_DEBUG, "writing %s-%s FILES information back to db\n", + _alpm_log(db->handle, PM_LOG_DEBUG, "writing %s-%s FILES information back to db\n", info->name, info->version); snprintf(path, PATH_MAX, "%sfiles", pkgpath); if((fp = fopen(path, "w")) == NULL) { - _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); + _alpm_log(db->handle, PM_LOG_ERROR, _("could not open file %s: %s\n"), + path, strerror(errno)); retval = -1; goto cleanup; } @@ -908,7 +911,7 @@ done: closedir(dbdir); } - _alpm_log(PM_LOG_DEBUG, "local database version %d\n", version); + _alpm_log(db->handle, PM_LOG_DEBUG, "local database version %d\n", version); return version; } @@ -922,7 +925,7 @@ pmdb_t *_alpm_db_register_local(pmhandle_t *handle) { pmdb_t *db; - _alpm_log(PM_LOG_DEBUG, "registering local database\n"); + _alpm_log(handle, PM_LOG_DEBUG, "registering local database\n"); db = _alpm_db_new("local", 1); if(db == NULL) { |