jw.pkg.App: Remove .debug() and friends

Replace the jw.pkg.App.debug(), .warn() and .err() methods by the
global log() function. There's no obvious benefit in having App know
what's logged.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-01-25 15:18:27 +01:00
commit 95fa2f0d06
8 changed files with 39 additions and 41 deletions

View file

@ -3,6 +3,7 @@
import re
from argparse import Namespace, ArgumentParser
from ...lib.log import *
from ..Cmd import Cmd
class BaseCmdPkgRelations(Cmd):
@ -14,9 +15,9 @@ class BaseCmdPkgRelations(Cmd):
subsecs.append('jw')
else:
subsecs = args.subsections.split(',')
self.app.debug('flavour = ', args.flavour, ', subsecs = ', ' '.join(subsecs))
log(DEBUG, 'flavour = ', args.flavour, ', subsecs = ', ' '.join(subsecs))
ignore = args.ignore.split(',')
self.app.debug("ignore = ", ignore)
log(DEBUG, "ignore = ", ignore)
r = []
flavours = args.flavour.split(',')
@ -68,7 +69,7 @@ class BaseCmdPkgRelations(Cmd):
raise Exception("Unknown version specifier in " + spec)
cleaned_dep = ' '.join(dep)
if not cleaned_dep in r:
self.app.debug("appending", cleaned_dep)
log(DEBUG, "appending", cleaned_dep)
r.append(cleaned_dep)
return args.delimiter.join(r)

View file

@ -3,6 +3,7 @@
import os, re, sys, subprocess, datetime, time
from argparse import Namespace, ArgumentParser
from ...lib.log import *
from ..Cmd import Cmd
class CmdBuild(Cmd): # export
@ -34,10 +35,10 @@ class CmdBuild(Cmd): # export
r = self.app.get_modules_from_project_txt([ cur ], ['pkg.requires.jw'],
prereq_type, scope = 2, add_self=False, names_only=True)
self.app.debug('prerequisites = ' + ' '.join(r))
log(DEBUG, 'prerequisites = ' + ' '.join(r))
if cur in r:
r.remove(cur)
self.app.debug('inserting', prereq_type, "prerequisites of", cur, ":", ' '.join(r))
log(DEBUG, 'inserting', prereq_type, "prerequisites of", cur, ":", ' '.join(r))
self.app.dep_cache[prereq_type][cur] = r
return r
@ -45,14 +46,14 @@ class CmdBuild(Cmd): # export
return self.app.res_cache.run(read_deps, [ cur, prereq_type ])
def add_dep_tree(cur, prereq_types, tree, all_deps):
self.app.debug("adding prerequisites " + ' '.join(prereq_types) + " of module " + cur)
log(DEBUG, "adding prerequisites " + ' '.join(prereq_types) + " of module " + cur)
if cur in all_deps:
self.app.debug('already handled module ' + cur)
log(DEBUG, 'already handled module ' + cur)
return 0
deps = set()
all_deps.add(cur)
for t in prereq_types:
self.app.debug("checking prereqisites of type " + t)
log(DEBUG, "checking prereqisites of type " + t)
deps.update(read_deps_cached(cur, t))
for d in deps:
add_dep_tree(d, prereq_types, tree, all_deps)
@ -63,7 +64,7 @@ class CmdBuild(Cmd): # export
all_deps = set()
dep_tree = {}
for m in modules:
self.app.debug("--- adding dependency tree of module " + m)
log(DEBUG, "--- adding dependency tree of module " + m)
add_dep_tree(m, prereq_types, dep_tree, all_deps)
while len(all_deps):
# Find any leaf
@ -128,7 +129,7 @@ class CmdBuild(Cmd): # export
def run(args):
self.app.debug("----------------------------------------- running ", ' '.join(sys.argv))
log(DEBUG, "----------------------------------------- running ", ' '.join(sys.argv))
modules = args.modules
exclude = args.exclude.split()

View file

@ -2,6 +2,7 @@
from argparse import Namespace, ArgumentParser
from ...lib.log import *
from ..Cmd import Cmd
class CmdCheck(Cmd): # export
@ -22,10 +23,10 @@ class CmdCheck(Cmd): # export
temp = set()
while len(unvisited) != 0:
m = unvisited[0]
self.app.debug('Checking circular dependency of', m)
log(DEBUG, 'Checking circular dependency of', m)
last = self.app.check_circular_deps(m, args.flavour, self.app.flip_graph(graph), unvisited, temp, path)
if last is not None:
self.app.debug('Found circular dependency below', m, ', last is', last)
log(DEBUG, 'Found circular dependency below', m, ', last is', last)
print('Found circular dependency in flavour', args.flavour, ':', ' -> '.join(path))
exit(1)
print('No circular dependency found for flavour', args.flavour, ' in modules:',

View file

@ -4,8 +4,9 @@ import re, os
from argparse import Namespace, ArgumentParser
from urllib.parse import urlparse
from ..Cmd import Cmd
from ...lib.log import *
from ...lib.util import run_cmd
from ..Cmd import Cmd
class CmdGetAuthInfo(Cmd): # export
@ -25,7 +26,7 @@ class CmdGetAuthInfo(Cmd): # export
# --- Milk jw-pkg repo
jw_pkg_dir = self.app.find_dir('jw-pkg', pretty=False)
if not os.path.isdir(jw_pkg_dir + '/.git'):
self.app.debug(f'jw-pkg directory is not a Git repo: {jw_pkg_dir}')
log(DEBUG, f'jw-pkg directory is not a Git repo: {jw_pkg_dir}')
return
remotes = run_cmd(['git', '-C', jw_pkg_dir, 'remote', '-v'])
result: dict[str, str] = {}

View file

@ -2,6 +2,7 @@
from argparse import Namespace, ArgumentParser
from ...lib.log import *
from ..Cmd import Cmd
class CmdModules(Cmd): # export
@ -16,10 +17,10 @@ class CmdModules(Cmd): # export
def _run(self, args: Namespace) -> None:
import pathlib
proj_root = self.app.projs_root
self.app.debug("proj_root = " + proj_root)
log(DEBUG, "proj_root = " + proj_root)
path = pathlib.Path(self.app.projs_root)
modules = [p.parents[1].name for p in path.glob('*/make/project.conf')]
self.app.debug("modules = ", modules)
log(DEBUG, "modules = ", modules)
out = []
filters = None if args.filter is None else [re.split("=", f) for f in re.split(",", args.filter)]
for m in modules:
@ -33,7 +34,7 @@ class CmdModules(Cmd): # export
sec = None
key = path[0]
val = self.app.get_value(m, sec, key)
self.app.debug('Checking in {} if {}="{}", is "{}"'.format(m, f[0], f[1], val))
log(DEBUG, 'Checking in {} if {}="{}", is "{}"'.format(m, f[0], f[1], val))
if val and val == f[1]:
out.append(m)
break

View file

@ -2,6 +2,7 @@
from argparse import Namespace, ArgumentParser
from ...lib.log import *
from ..Cmd import Cmd
class CmdProjDir(Cmd): # export
@ -18,7 +19,7 @@ class CmdProjDir(Cmd): # export
for m in args.module:
path = self.app.find_dir(m)
if path is None:
self.app.warn(f'No project directory for module "{m}: {e}')
log(WARNING, f'No project directory for module "{m}: {e}')
continue
out.append(path)
if out:

View file

@ -2,6 +2,7 @@
from argparse import Namespace, ArgumentParser
from ...lib.log import *
from ..Cmd import Cmd
# TODO: seems at least partly redundant to CmdPkgRequires / print_pkg_relations
@ -23,7 +24,7 @@ class CmdRequiredOsPkg(Cmd): # export
if 'build' in flavours and not 'run' in flavours:
# TODO: This adds too much. Only the run dependencies of the build dependencies would be needed.
flavours.append('run')
self.app.debug("flavours = " + args.flavours)
log(DEBUG, "flavours = " + args.flavours)
deps = self.app.get_modules_from_project_txt(modules, ['pkg.requires.jw'], flavours,
scope = 2, add_self=True, names_only=True)
if args.skip_excluded:
@ -31,7 +32,7 @@ class CmdRequiredOsPkg(Cmd): # export
if self.app.is_excluded_from_build(d) is not None:
deps.remove(d)
subsecs = self.app.os_cascade()
self.app.debug("subsecs = ", subsecs)
log(DEBUG, "subsecs = ", subsecs)
requires = []
for s in subsecs:
for f in flavours: