Az.Cli icon indicating copy to clipboard operation
Az.Cli copied to clipboard

Disable logging of library

Open khaitranhq opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. When I import az.cli and logging, logging show the log of az.cli as well. Describe the solution you'd like An option or property to disable logs of az.cli. I think there should be an if command at these lines https://github.com/MarkWarneke/Az.Cli/blob/c69eed85afb81bcb34e49b87ef81608f18fc137c/src/az/cli.py#L67-L75

Additional context image

khaitranhq avatar Aug 15 '22 05:08 khaitranhq

I am with same issue! Someone knows how to solve?

edtroleis avatar Sep 22 '22 13:09 edtroleis

I was wrangling with the logging part a bit.

I did not yet find the time yet to investigate this further.
If someone has a better way to disable the internal CLI log outputs I would very much appreciate some help.

MarkWarneke avatar Sep 22 '22 14:09 MarkWarneke

I've tried some methods, but unfortunatelly unsucessfully!

import logging
from az.cli import az
logging.getLogger('az').setLevel(logging.ERROR)
...
...
az("ad group show --group GROUP_NAME -o none")
...
...
az("ad group show --group GROUP_NAME --only-show-errors")
...

Regards.

edtroleis avatar Sep 22 '22 14:09 edtroleis

It took me several days to find out how to disable the log of CLI. Fortunately, I found another cool library for logging: https://github.com/Delgan/loguru. Using this library won't show any log of AZ CLI.

Hope that it can help you

khaitranhq avatar Sep 22 '22 14:09 khaitranhq