Move "create|delete reference ..." messages to own sub logger

With some of the newer changes (most probably the global repo state),
these log messages could increase the amount of log messages in a Zuul
deployment quite heavily.

Thus move them into its own sub logger so it can be stripped or split
out via log config if needed without sacrificing other usefull logs
from zuul.Repo.

Change-Id: I6206a5938e788733950451292403d2b2525753ed
This commit is contained in:
Felix Edel 2021-05-17 08:04:07 +02:00
parent ddb7259f0d
commit 465ac84cfb
1 changed files with 13 additions and 8 deletions

View File

@ -441,9 +441,10 @@ class Repo(object):
return repo.refs
def setRef(self, path, hexsha, repo=None, zuul_event_id=None):
log = get_annotated_logger(self.log, zuul_event_id)
log.debug("Create reference %s at %s in %s",
path, hexsha, self.local_path)
ref_log = get_annotated_logger(
logging.getLogger("zuul.Repo.Ref"), zuul_event_id)
ref_log.debug("Create reference %s at %s in %s",
path, hexsha, self.local_path)
if repo is None:
repo = self.createRepoObject(zuul_event_id)
self._setRef(path, hexsha, repo)
@ -458,8 +459,9 @@ class Repo(object):
def setRefs(self, refs, keep_remotes=False, zuul_event_id=None):
repo = self.createRepoObject(zuul_event_id)
log = get_annotated_logger(self.log, zuul_event_id)
self._setRefs(repo, refs, keep_remotes=keep_remotes, log=log)
ref_log = get_annotated_logger(
logging.getLogger("zuul.Repo.Ref"), zuul_event_id)
self._setRefs(repo, refs, keep_remotes=keep_remotes, log=ref_log)
@staticmethod
def setRefsAsync(local_path, refs, keep_remotes=False):
@ -503,10 +505,11 @@ class Repo(object):
origin_ref.commit = rev
def deleteRef(self, path, repo=None, zuul_event_id=None):
log = get_annotated_logger(self.log, zuul_event_id)
ref_log = get_annotated_logger(
logging.getLogger("zuul.Repo.Ref"), zuul_event_id)
if repo is None:
repo = self.createRepoObject(zuul_event_id)
log.debug("Delete reference %s", path)
ref_log.debug("Delete reference %s", path)
Repo._deleteRef(path, repo)
@staticmethod
@ -976,8 +979,10 @@ class Merger(object):
Repo.setRefsAsync, repo.local_path, project,
keep_remotes=self.execution_context)
messages = job.result()
ref_log = get_annotated_logger(
logging.getLogger("zuul.Repo.Ref"), zuul_event_id)
for message in messages:
log.debug(message)
ref_log.debug(message)
def _mergeChange(self, item, ref, zuul_event_id):
log = get_annotated_logger(self.log, zuul_event_id)