Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds --log=LEVEL to allow specifying verbosity. #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions adb-sync
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,15 @@ def FixPath(src: bytes, dst: bytes) -> Tuple[bytes, bytes]:
return (src, dst)


def main() -> None:
logging.basicConfig(level=logging.INFO)
def GetLogLevel(name: str) -> int:
"""Returns the numeric value for the named logging level."""
level = getattr(logging, name.upper(), logging.INFO)
if not isinstance(level, int):
return logging.INFO
return level


def main() -> None:
parser = argparse.ArgumentParser(
description='Synchronize a directory between an Android device and the '
'local file system')
Expand Down Expand Up @@ -792,12 +798,21 @@ def main() -> None:
'--copy-links',
action='store_true',
help='transform symlink into referent file/dir')
parser.add_argument(
'--log',
metavar='LEVEL',
default='INFO',
type=str,
help='Minimum log level to display - one of: '
'DEBUG INFO WARNING ERROR CRITICAL (default: INFO).')
parser.add_argument(
'--dry-run',
action='store_true',
help='Do not do anything - just show what would be done.')
args = parser.parse_args()

logging.basicConfig(level=GetLogLevel(args.log))

localpatterns = [os.fsencode(x) for x in args.source]
remotepath = os.fsencode(args.destination)
adb_args = os.fsencode(args.adb).split(b' ')
Expand Down