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

apps: parse log level with logging.getLevelName() #2555

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
15 changes: 1 addition & 14 deletions apps/blueman-adapters.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,7 @@ if __name__ == '__main__':
parser.add_argument("--socket-id", dest="socket_id", action="store", type=int, metavar="ID")
parser.add_argument("adapter", nargs="?", metavar="ADAPTER NAME")
args = parser.parse_args()

if args.LEVEL.upper() == "DEBUG":
log_level = logging.DEBUG
elif args.LEVEL.upper() == "INFO":
log_level = logging.INFO
elif args.LEVEL.upper() == "WARNING":
log_level = logging.WARNING
elif args.LEVEL.upper() == "ERROR":
log_level = logging.ERROR
elif args.LEVEL.upper() == "CRITICAL":
log_level = logging.CRITICAL
else:
log_level = logging.WARNING

log_level = logging.getLevelName(args.LEVEL.upper())
create_logger(log_level, "blueman-adapters", syslog=args.syslog)

set_proc_title()
Expand Down
15 changes: 1 addition & 14 deletions apps/blueman-applet.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,7 @@ from blueman.main.Applet import BluemanApplet
if __name__ == '__main__':
parser = create_parser()
args = parser.parse_args()

if args.LEVEL.upper() == "DEBUG":
log_level = logging.DEBUG
elif args.LEVEL.upper() == "INFO":
log_level = logging.INFO
elif args.LEVEL.upper() == "WARNING":
log_level = logging.WARNING
elif args.LEVEL.upper() == "ERROR":
log_level = logging.ERROR
elif args.LEVEL.upper() == "CRITICAL":
log_level = logging.CRITICAL
else:
log_level = logging.WARNING

log_level = logging.getLevelName(args.LEVEL.upper())
create_logger(log_level, "blueman-applet", syslog=args.syslog)

set_proc_title()
Expand Down
15 changes: 1 addition & 14 deletions apps/blueman-manager.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,7 @@ from blueman.Functions import set_proc_title, create_parser, create_logger
if __name__ == '__main__':
parser = create_parser()
args = parser.parse_args()

if args.LEVEL.upper() == "DEBUG":
log_level = logging.DEBUG
elif args.LEVEL.upper() == "INFO":
log_level = logging.INFO
elif args.LEVEL.upper() == "WARNING":
log_level = logging.WARNING
elif args.LEVEL.upper() == "ERROR":
log_level = logging.ERROR
elif args.LEVEL.upper() == "CRITICAL":
log_level = logging.CRITICAL
else:
log_level = logging.WARNING

log_level = logging.getLevelName(args.LEVEL.upper())
create_logger(log_level, "blueman-manager", syslog=args.syslog)

app = Blueman()
Expand Down
14 changes: 1 addition & 13 deletions apps/blueman-mechanism.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,7 @@ parser.add_argument("-d", "--debug", dest="debug", action="store_true")
parser.add_argument("-s", "--stop-timer", dest="stoptimer", action="store_true")
args = parser.parse_args()

if args.LEVEL.upper() == "DEBUG":
log_level = logging.DEBUG
elif args.LEVEL.upper() == "INFO":
log_level = logging.INFO
elif args.LEVEL.upper() == "WARNING":
log_level = logging.WARNING
elif args.LEVEL.upper() == "ERROR":
log_level = logging.ERROR
elif args.LEVEL.upper() == "CRITICAL":
log_level = logging.CRITICAL
else:
log_level = logging.WARNING

log_level = logging.getLevelName(args.LEVEL.upper())
logger = create_logger(log_level, "blueman-mechanism", syslog=True)

if args.debug:
Expand Down
15 changes: 1 addition & 14 deletions apps/blueman-sendto.in
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,7 @@ if __name__ == '__main__':
help=_("Files to be send to the bluetooth device"))

args = parser.parse_args()

if args.LEVEL.upper() == "DEBUG":
log_level = logging.DEBUG
elif args.LEVEL.upper() == "INFO":
log_level = logging.INFO
elif args.LEVEL.upper() == "WARNING":
log_level = logging.WARNING
elif args.LEVEL.upper() == "ERROR":
log_level = logging.ERROR
elif args.LEVEL.upper() == "CRITICAL":
log_level = logging.CRITICAL
else:
log_level = logging.WARNING

log_level = logging.getLevelName(args.LEVEL.upper())
create_logger(log_level, "blueman-sendto", syslog=args.syslog)

set_proc_title()
Expand Down
15 changes: 1 addition & 14 deletions apps/blueman-services.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,7 @@ from blueman.main.Services import BluemanServices
if __name__ == '__main__':
parser = create_parser()
args = parser.parse_args()

if args.LEVEL.upper() == "DEBUG":
log_level = logging.DEBUG
elif args.LEVEL.upper() == "INFO":
log_level = logging.INFO
elif args.LEVEL.upper() == "WARNING":
log_level = logging.WARNING
elif args.LEVEL.upper() == "ERROR":
log_level = logging.ERROR
elif args.LEVEL.upper() == "CRITICAL":
log_level = logging.CRITICAL
else:
log_level = logging.WARNING

log_level = logging.getLevelName(args.LEVEL.upper())
create_logger(log_level, "blueman-services", syslog=args.syslog)

setup_icon_path()
Expand Down
15 changes: 1 addition & 14 deletions apps/blueman-tray.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,7 @@ from blueman.main.Tray import BluemanTray
if __name__ == '__main__':
parser = create_parser()
args = parser.parse_args()

if args.LEVEL.upper() == "DEBUG":
log_level = logging.DEBUG
elif args.LEVEL.upper() == "INFO":
log_level = logging.INFO
elif args.LEVEL.upper() == "WARNING":
log_level = logging.WARNING
elif args.LEVEL.upper() == "ERROR":
log_level = logging.ERROR
elif args.LEVEL.upper() == "CRITICAL":
log_level = logging.CRITICAL
else:
log_level = logging.WARNING

log_level = logging.getLevelName(args.LEVEL.upper())
create_logger(log_level, "blueman-tray", syslog=args.syslog)

set_proc_title()
Expand Down
2 changes: 1 addition & 1 deletion blueman/Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def create_parser(
parser = argparse.ArgumentParser()

if loglevel:
parser.add_argument("--loglevel", dest="LEVEL", default="warning")
parser.add_argument("--loglevel", dest="LEVEL", default="WARNING")

if syslog:
parser.add_argument("--syslog", dest="syslog", action="store_true")
Expand Down
Loading