Skip to content

Commit 9719cb8

Browse files
author
Trong Nhan Mai
committed
chore: improve output log for build spec gen
1 parent 7c0dc36 commit 9719cb8

File tree

4 files changed

+162
-131
lines changed

4 files changed

+162
-131
lines changed

src/macaron/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def gen_build_spec(gen_build_spec_args: argparse.Namespace) -> int:
276276
logger.error("Error while generate reproducible central build spec.")
277277
return os.EX_DATAERR
278278

279-
logger.debug(build_spec_content)
279+
logger.debug("Build spec content: \n%s", build_spec_content)
280280
build_spec_filepath = os.path.join(global_config.output_path, "macaron.buildspec")
281281
try:
282282
with open(build_spec_filepath, mode="w", encoding="utf-8") as file:

src/macaron/build_spec_generator/jdk_finder.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,14 @@ def get_jdk_version_from_jar(artifact_path: str) -> str | None:
126126
for line in manifest_content.splitlines():
127127
if "Build-Jdk" in line or "Build-Jdk-Spec" in line:
128128
_, _, version = line.rpartition(":")
129+
logger.debug(
130+
"Found JDK version %s from java artifact at %s",
131+
version.strip(),
132+
artifact_path,
133+
)
129134
return version.strip()
130135

136+
logger.debug("Cannot find any JDK version from java artifact at %s", artifact_path)
131137
return None
132138

133139

@@ -175,7 +181,10 @@ def find_jdk_version_from_remote_maven_repo_standalone(
175181
remote_maven_repo_url,
176182
maven_repository_path,
177183
)
178-
184+
logger.debug(
185+
"Find JDK version from jar at %s, using temporary file.",
186+
artifact_url,
187+
)
179188
with tempfile.TemporaryDirectory() as temp_dir_name:
180189
local_artifact_path = os.path.join(temp_dir_name, asset_name)
181190
try:
@@ -253,6 +262,11 @@ def find_jdk_version_from_remote_maven_repo_cache(
253262
remote_maven_repo_url,
254263
maven_repository_path,
255264
)
265+
logger.debug(
266+
"Find JDK version from jar at %s, using cache %s",
267+
artifact_url,
268+
local_artifact_path,
269+
)
256270
try:
257271
download_file(
258272
artifact_url,

src/macaron/build_spec_generator/macaron_db_extractor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ def lookup_one_or_none(
119119
def compile_sqlite_select_statement(select_statment: Select) -> str:
120120
"""Return the equivalent SQLite SELECT statement from an SQLAlchemy SELECT statement.
121121
122+
This function also introduces additional cosmetic details so that it can be easily
123+
read from the log.
124+
122125
Parameters
123126
----------
124127
select_statement : Select
@@ -129,11 +132,11 @@ def compile_sqlite_select_statement(select_statment: Select) -> str:
129132
str
130133
The equivalent SQLite SELECT statement as a string.
131134
"""
132-
sqlite_str = select_statment.compile(
135+
compiled_sqlite = select_statment.compile(
133136
dialect=sqlite.dialect(), # type: ignore
134137
compile_kwargs={"literal_binds": True},
135138
)
136-
return str(sqlite_str)
139+
return f"\n----- Begin SQLite query \n{str(compiled_sqlite)}\n----- End SQLite query\n"
137140

138141

139142
def get_sql_stmt_latest_component_for_purl(purl: PackageURL) -> Select[tuple[Component]]:

0 commit comments

Comments
 (0)