Skip to content

Commit

Permalink
Streamline function call
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenning committed Oct 11, 2023
1 parent dd3941d commit c8b4b0f
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions ciscoconfparse/ccp_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ def ccp_logger_control(
action="",
handler_id=None,
enqueue=True,
# rotation="00:00",
# retention="1 month",
# compression="zip",
level="DEBUG",
colorize=True,
debug=0,
Expand All @@ -202,34 +199,24 @@ def ccp_logger_control(
-------
"""

msg = "ccp_logger_control() was called with sink='{}', action='{}', handler_id='{}', enqueue={}, level='{}', colorize={}, debug={}".format(
sink,
action,
handler_id,
enqueue,
# rotation,
# retention,
# compression,
level,
colorize,
debug,
)
msg = f"ccp_logger_control() was called with sink='{sink}', action='{action}', handler_id='{handler_id}', enqueue={enqueue}, level='{level}', colorize={colorize}, debug={debug}"
if debug > 0:
logger.info(msg)

if not isinstance(action, str):
raise ValueError

assert action in ("remove", "add", "disable", "enable", "",)
if not action in set({"remove", "add", "disable", "enable",}):
error = f"{action} is invalid."
logger.critical(error)
raise ValueError(error)

package_name = "ciscoconfparse"

if action == "remove":
# Require an explicit loguru handler_id to remove...
if not isinstance(handler_id, int):
raise ValueError


logger.remove(handler_id)
return True

Expand Down Expand Up @@ -262,15 +249,8 @@ def ccp_logger_control(
logger.enable(package_name)
return True

elif action == "":
raise ValueError(
"action='' is not supported. Please use a valid action keyword"
)

else:
raise NotImplementedError(
"action='%s' is an unsupported logger action" % action
)
raise NotImplementedError(f"action='{action}' is an unsupported logger action")


@logger.catch(reraise=True)
Expand Down

0 comments on commit c8b4b0f

Please sign in to comment.