Skip to content

Commit

Permalink
add verbosity levels arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed Feb 19, 2025
1 parent f763e2d commit 88c71d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ __pycache__/

# Generated by build
/dist

# IDEs configs/caches
.vscode
.idea
.run
8 changes: 4 additions & 4 deletions src/flynt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def run_flynt_cli(arglist: Optional[List[str]] = None) -> int:
verbosity_group.add_argument(
"-v",
"--verbose",
action="store_true",
action="count",
help="run with verbose output",
default=False,
default=0,
)
verbosity_group.add_argument(
"-q",
Expand Down Expand Up @@ -194,8 +194,8 @@ def run_flynt_cli(arglist: Optional[List[str]] = None) -> int:
)

state = state_from_args(args)
if args.verbose:
logging.getLogger("flynt").setLevel(logging.DEBUG)
if args.verbose > 0:
logging.getLogger("flynt").setLevel(logging.DEBUG if args.verbose > 1 else logging.INFO)

if args.string:
content = " ".join(args.src)
Expand Down
5 changes: 3 additions & 2 deletions src/flynt/transform/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ def transform_chunk(
log.warning("Not converting code due to: %s", cr)
state.invalid_conversions += 1
return None, False # type:ignore # ideally should return one optional str
except Exception:
except Exception as exc:
msg = traceback.format_exc()
log.exception("Exception during conversion of code: %s", msg)
level = logging.DEBUG if isinstance(exc, AssertionError) else logging.EXCEPTION
log.log(level, "Exception during conversion of code: %s", msg)
state.invalid_conversions += 1
return None, False # type:ignore # ideally should return one optional str
else:
Expand Down

0 comments on commit 88c71d1

Please sign in to comment.