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 12, 2023
1 parent cb6024e commit 26b7b77
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 @@ -10,7 +10,7 @@
from codemodder.file_context import FileContext

from codemodder import registry, __VERSION__
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 @@ -132,7 +132,7 @@ def run(original_args) -> int:

configure_logger(argv.verbose)

logger.info("[startup]")
log_section("startup")
logger.info("codemodder: python/%s", __VERSION__)

context = CodemodExecutionContext(
Expand All @@ -151,7 +151,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 @@ -170,7 +170,7 @@ def run(original_args) -> int:
for name in full_names:
logger.debug(" - %s", name)

logger.info("[scanning]")
log_section("scanning")
# run codemods one at a time making sure to respect the given sequence
for codemod in codemods_to_run:
logger.info("running codemod %s", codemod.id)
Expand All @@ -190,7 +190,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))
all_failures = context.get_failed_files()
logger.info(
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 26b7b77

Please sign in to comment.