Skip to content

Commit

Permalink
Separate log section headers
Browse files Browse the repository at this point in the history
  • Loading branch information
drdavella committed Oct 10, 2023
1 parent b309ca0 commit ec75035
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/codemodder/codemodder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codemodder.file_context import FileContext

from codemodder import registry
from codemodder.logging import configure_logger, logger
from codemodder.logging import configure_logger, logger, log_section
from codemodder.cli import parse_args
from codemodder.code_directory import file_line_patterns, match_files
from codemodder.context import CodemodExecutionContext, ChangeSet
Expand Down Expand Up @@ -136,7 +136,7 @@ def run(original_args) -> int:

configure_logger(argv.verbose)

logger.info("[startup]")
log_section("startup")
# TODO: fix hardcoded version
logger.info("codemodder: python/%s", "0.57.0")

Expand All @@ -157,7 +157,7 @@ def run(original_args) -> int:
logger.error("No codemods to run")
return 0

logger.info("[setup]")
log_section("setup")
logger.info("running:")
for codemod in codemods_to_run:
logger.info(" - %s", codemod.id)
Expand All @@ -175,7 +175,7 @@ def run(original_args) -> int:
logger.debug("Matched files:\n%s", "\n".join(full_names))

# run codemods in sequence
logger.info("[scanning]")
log_section("scanning")
for codemod in codemods_to_run:
logger.info("running codemod %s", codemod.id)
results = codemod.apply(context)
Expand All @@ -194,7 +194,7 @@ def run(original_args) -> int:
elapsed_ms = int(elapsed.total_seconds() * 1000)
report_default(elapsed_ms, argv, original_args, results)

logger.info("[report]")
log_section("report")
logger.info("scanned: %s files", len(files_to_analyze))
logger.info(
"failed: %s files (%s unique)",
Expand Down
7 changes: 7 additions & 0 deletions src/codemodder/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class OutputFormat(Enum):
JSON = "json"


def log_section(section_name: str):
"""
Log a section header.
"""
logger.info("\n[%s]", section_name)


def configure_logger(verbose: bool):
"""
Configure the logger based on the verbosity level.
Expand Down

0 comments on commit ec75035

Please sign in to comment.