Skip to content

Commit

Permalink
Add (unused) --log-format flag
Browse files Browse the repository at this point in the history
  • Loading branch information
drdavella committed Oct 12, 2023
1 parent 30d2b5d commit 1fcb04f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/codemodder/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys

from codemodder import __VERSION__
from codemodder.logging import logger
from codemodder.logging import OutputFormat, logger


class ArgumentParser(argparse.ArgumentParser):
Expand Down Expand Up @@ -134,6 +134,13 @@ def parse_args(argv, codemod_registry):
action=argparse.BooleanOptionalAction,
help="print more to stdout",
)
parser.add_argument(
"--log-format",
type=OutputFormat,
default=OutputFormat.HUMAN,
choices=[str(x).split(".")[-1].lower() for x in list(OutputFormat)],
help="the format for the log output",
)
parser.add_argument(
"--path-exclude",
action=CsvListAction,
Expand Down
10 changes: 10 additions & 0 deletions src/codemodder/logging.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
from enum import Enum
import logging
import sys

logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.INFO)
logger = logging.getLogger("codemodder")


class OutputFormat(Enum):
"""
Enum for the output format of the logger.
"""

HUMAN = "human"
JSON = "json"


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

0 comments on commit 1fcb04f

Please sign in to comment.