summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-08-07 20:09:39 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2019-08-07 20:09:39 +0100
commit23d4bd86c9eb58b3049ff4c14fd31d4625f64a2a (patch)
tree96c7aa17ce74d8a967f1061baf6da786f97dc259
parentTidier git pointer typedefs (diff)
downloadgentoobrowse-api-23d4bd86c9eb58b3049ff4c14fd31d4625f64a2a.tar.bz2
gentoobrowse-api-23d4bd86c9eb58b3049ff4c14fd31d4625f64a2a.tar.xz
gentoobrowse-api-23d4bd86c9eb58b3049ff4c14fd31d4625f64a2a.zip
Switch to IceTray loggers
Some tidyup probably required
-rw-r--r--gentoobrowse-api/service/maintenanceBugs.cpp14
-rw-r--r--gentoobrowse-api/service/maintenanceGitOperations.cpp24
-rw-r--r--gentoobrowse-api/service/utils/git.cpp19
3 files changed, 33 insertions, 24 deletions
diff --git a/gentoobrowse-api/service/maintenanceBugs.cpp b/gentoobrowse-api/service/maintenanceBugs.cpp
index 04a595e..73b5b63 100644
--- a/gentoobrowse-api/service/maintenanceBugs.cpp
+++ b/gentoobrowse-api/service/maintenanceBugs.cpp
@@ -14,6 +14,7 @@
#include <lexer-regex.h>
#include <utils/dbUtils.h>
#include <compileTimeFormatter.h>
+#include <logger.h>
namespace Gentoo {
namespace Service {
@@ -68,16 +69,17 @@ namespace Gentoo {
Glib::ustring summary;
};
- AdHocFormatter(UpdatingBugs, "Refreshing bug list from %?\n");
- AdHocFormatter(UpdatingBugUrl, " ... %?\n");
- AdHocFormatter(UpdatingBugsResult, "Refreshed bug list: %? added, %? updated, %? removed\n");
+ AdHocFormatter(UpdatingBugs, "Refreshing bug list from %?");
+ AdHocFormatter(UpdatingBugUrl, " ... %?");
+ AdHocFormatter(UpdatingBugsResult, "Refreshed bug list: %? added, %? updated, %? removed");
void
Maintenance::refreshBugs(const Ice::Current & c)
{
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
std::filesystem::path root = properties(c)->getPropertyWithDefault(
"GentooBrowseAPI.BugRoot", "https://bugs.gentoo.org/data/cached");
- UpdatingBugs::write(std::cerr, root);
+ log->messagectf<UpdatingBugs>(IceTray::Logging::LogLevel::INFO, root);
auto dbc = db->get();
DB::TransactionScope tx(*dbc.get());
DB::TablePatch tp;
@@ -91,14 +93,14 @@ namespace Gentoo {
"buglist-CONFIRMED.html",
"buglist-UNCONFIRMED.html",
"buglist-IN_PROGRESS.html" }) {
- UpdatingBugUrl::write(std::cerr, bl);
+ log->messagectf<UpdatingBugUrl>(IceTray::Logging::LogLevel::DEBUG, bl);
AdHoc::Net::CurlStreamSource css((root / bl).string());
css.setopt(CURLOPT_ENCODING, "deflate, gzip");
AdHoc::Net::CurlStream cs(css);
blp.parse_stream(cs);
}
auto result = dbc->patchTable(&tp);
- UpdatingBugsResult::write(std::cerr, result.inserts, result.updates, result.deletes);
+ log->messagectf<UpdatingBugsResult>(IceTray::Logging::LogLevel::INFO, result.inserts, result.updates, result.deletes);
Utils::Database::drop(dbc.get(), tp.src);
}
}
diff --git a/gentoobrowse-api/service/maintenanceGitOperations.cpp b/gentoobrowse-api/service/maintenanceGitOperations.cpp
index 1b59e43..dae0da2 100644
--- a/gentoobrowse-api/service/maintenanceGitOperations.cpp
+++ b/gentoobrowse-api/service/maintenanceGitOperations.cpp
@@ -14,6 +14,7 @@
#include "converters.impl.h"
#include <compileTimeFormatter.h>
#include <systemd/sd-daemon.h>
+#include <logger.h>
namespace Gentoo {
namespace Service {
@@ -39,13 +40,14 @@ namespace Gentoo {
return onFile(delta, fileset);
}
- AdHocFormatter(UpdatingChangeLog, "Updating change log for repository %? with range %?...%?\n");
- AdHocFormatter(UpdatedChangeLog, "Updated change log for repository %?, added %? new entries\n");
+ AdHocFormatter(UpdatingChangeLog, "Updating change log for repository %? with range %?...%?");
+ AdHocFormatter(UpdatedChangeLog, "Updated change log for repository %?, added %? new entries");
static
void
writeChangeLog(DB::Connection * db, int64_t repoId, git_repository * repo, const git_oid & lastCommitOid, const git_oid & headCommitOid)
{
- UpdatingChangeLog::write(std::cerr, repoId, lastCommitOid, headCommitOid);
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
+ log->messagectf<UpdatingChangeLog>(IceTray::Logging::LogLevel::INFO, repoId, lastCommitOid, headCommitOid);
auto cli = sql::maintenance::changeLogInsert.modify(db);
cli->bindParamI(0, repoId);
// Set up walker
@@ -87,7 +89,7 @@ namespace Gentoo {
cli->bindParamS(7, Slicer::packPqArray(fs));
count += cli->execute();
}
- UpdatedChangeLog::write(std::cerr, repoId, count);
+ log->messagectf<UpdatedChangeLog>(IceTray::Logging::LogLevel::INFO, repoId, count);
}
void
@@ -148,11 +150,12 @@ namespace Gentoo {
return writeChangesToFileList(repository.repoid, repo.get(), lastCommitOid, headCommitOid);
}
- AdHocFormatter(FindingChanges, "Finding changes for repository %? with range %?...%?\n");
+ AdHocFormatter(FindingChanges, "Finding changes for repository %? with range %?...%?");
ChangeSet
writeChangesToFileList(int64_t repoId, git_repository * repo, const git_oid & lastCommitOid, const git_oid & headCommitOid)
{
- FindingChanges::write(std::cerr, repoId, lastCommitOid, headCommitOid);
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
+ log->messagectf<FindingChanges>(IceTray::Logging::LogLevel::DEBUG, repoId, lastCommitOid, headCommitOid);
auto lastCommit = gitSafeGet(git_commit_lookup, git_commit_free, repo, &lastCommitOid);
auto headCommit = gitSafeGet(git_commit_lookup, git_commit_free, repo, &headCommitOid);
auto lastTree = gitSafeGet(git_commit_tree, git_tree_free, lastCommit.get());
@@ -178,12 +181,13 @@ namespace Gentoo {
sd_notifyf(0, "STATUS=Last update %s", ctime(&now));
}
- AdHocFormatter(UpdatingFileContent, "Updating file content\n");
- AdHocFormatter(UpdatedFileContent, "Updated file content\n");
+ AdHocFormatter(UpdatingFileContent, "Updating file content");
+ AdHocFormatter(UpdatedFileContent, "Updated file content");
void
Maintenance::applyFileChanges(DB::Connection * dbc, const std::filesystem::path & repoRoot, const Repository & repo, ChangeSet & changes) const
{
- UpdatingFileContent::write(std::cerr);
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
+ log->messagectf<UpdatingFileContent>(IceTray::Logging::LogLevel::DEBUG);
// Map of phase, to order, to processor
std::map<unsigned char, std::multimap<unsigned char, FileProcessorPtr>> fps;
for (const auto & fpf : AdHoc::PluginManager::getDefault()->getAll<FileProcessorFactory>()) {
@@ -228,7 +232,7 @@ namespace Gentoo {
processor.second->tidy(dbc);
}
}
- UpdatedFileContent::write(std::cerr);
+ log->messagectf<UpdatedFileContent>(IceTray::Logging::LogLevel::DEBUG);
}
}
diff --git a/gentoobrowse-api/service/utils/git.cpp b/gentoobrowse-api/service/utils/git.cpp
index 9a1cae2..450bfec 100644
--- a/gentoobrowse-api/service/utils/git.cpp
+++ b/gentoobrowse-api/service/utils/git.cpp
@@ -2,6 +2,7 @@
#include <maintenance.h>
#include <execinfo.h>
#include <compileTimeFormatter.h>
+#include <logger.h>
namespace Gentoo {
namespace Utils {
@@ -46,11 +47,12 @@ namespace Gentoo {
return gitSafeGet(git_annotated_commit_from_revspec, git_annotated_commit_free, repo, "FETCH_HEAD");
}
- AdHocFormatter(FastForward, "Performing fast-forward %? -> %?\n");
- AdHocFormatter(CheckOut, "Checking out %?\n");
+ AdHocFormatter(FastForward, "Performing fast-forward %? -> %?");
+ AdHocFormatter(CheckOut, "Checking out %?");
git_oid
gitFastForward(git_repository * repo, const git_annotated_commit * fetch_head)
{
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
// Test fast-forward is possible
const git_annotated_commit * heads[] = { fetch_head };
git_merge_analysis_t analysis = GIT_MERGE_ANALYSIS_NONE;
@@ -68,28 +70,29 @@ namespace Gentoo {
// Perform fast-forward
auto fetch_head_id = *git_annotated_commit_id(fetch_head);
auto fetch_head_object = gitSafeGet(git_object_lookup, git_object_free, repo, &fetch_head_id, GIT_OBJ_ANY);
- FastForward::write(std::cerr, *git_reference_target(head.get()), fetch_head_id);
+ log->messagectf<FastForward>(IceTray::Logging::LogLevel::INFO, *git_reference_target(head.get()), fetch_head_id);
gitSafeGet(git_reference_set_target, git_reference_free, head.get(), &fetch_head_id, "fast-forward");
// Checkout new head
- CheckOut::write(std::cerr, fetch_head_id);
+ log->messagectf<CheckOut>(IceTray::Logging::LogLevel::INFO, fetch_head_id);
auto checkout_options = gitSafeGet(git_checkout_init_options, 0u + GIT_CHECKOUT_OPTIONS_VERSION);
checkout_options.checkout_strategy = GIT_CHECKOUT_FORCE;
gitSafe(git_checkout_head, repo, &checkout_options);
return fetch_head_id;
}
- AdHocFormatter(Updating, "Updating repository in %? from %?/%?\n");
- AdHocFormatter(UpdateComplete, "Update complete to %?\n");
+ AdHocFormatter(Updating, "Updating repository in %? from %?/%?");
+ AdHocFormatter(UpdateComplete, "Update complete to %?");
void
updateRepository(const std::string & path, const std::string & upstream, const std::string & branch)
{
- Updating::write(std::cerr, path, upstream, branch);
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
+ log->messagectf<Updating>(IceTray::Logging::LogLevel::INFO, path, upstream, branch);
auto repo = gitSafeGet(git_repository_open, git_repository_free, path.c_str());
auto origin = gitSafeGet(git_remote_lookup, git_remote_free, repo.get(), upstream.c_str());
auto fetchHead = gitFetch(repo.get(), origin.get(), branch.c_str());
auto oid = gitFastForward(repo.get(), fetchHead.get());
- UpdateComplete::write(std::cerr, oid);
+ log->messagectf<UpdateComplete>(IceTray::Logging::LogLevel::INFO, oid);
}
}
}