Skip to content

Commit

Permalink
logging cache invalidation operations
Browse files Browse the repository at this point in the history
  • Loading branch information
chubin committed Jul 7, 2019
1 parent 8f78c78 commit a9fa608
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def _config_locations():
"path.internal.vim": os.path.join(_MYDIR, "share/vim"),
"path.log.main": "log/main.log",
"path.log.queries": "log/queries.log",
"path.log.fetch": "log/fetch.log",
"path.repositories": "upstream",
"path.spool": "spool",
"path.workdir": _WORKDIR,
Expand Down
30 changes: 27 additions & 3 deletions lib/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
Ths module makes real network and OS interaction,
and the adapters only say how exctly this interaction
should be done.
Configuration parameters:
* path.log.fetch
"""

import sys
import logging
import os
import subprocess
import textwrap
Expand All @@ -15,8 +20,16 @@
import adapter
import cache

def _log(message):
sys.stdout.write(message)
from config import CONFIG

def _log(*message):
logging.info(*message)
if len(message) > 1:
message = message[0].rstrip("\n") % tuple(message[1:])
else:
message = message[0].rstrip("\n")

sys.stdout.write(message+"\n")

def _run_cmd(cmd):
shell = isinstance(cmd, str)
Expand Down Expand Up @@ -123,10 +136,16 @@ def _update_adapter(adptr):
updates = output.splitlines()

entries = adptr.get_updates_list(updates)
if entries:
_log("%s Entries to be updated: %s", adptr, len(entries))

for entry in entries:
print "ivalidating ", entry
_log("+ ivalidating %s", entry)
cache.delete(entry)

if entries:
_log("Done")

adptr.save_state(state)
return True

Expand Down Expand Up @@ -175,6 +194,11 @@ def main(args):
_show_usage()
sys.exit(0)

logging.basicConfig(
filename=CONFIG["path.log.fetch"],
level=logging.DEBUG,
format='%(asctime)s %(message)s')

if args[0] == 'fetch-all':
fetch_all()
elif args[0] == 'update':
Expand Down

0 comments on commit a9fa608

Please sign in to comment.