Merge branch 'bug/verbose-console' into 'dev'

Fix debug logging to only display with the -v (verbose) flag

See merge request crafty-controller/crafty-4!560
This commit is contained in:
Iain Powrie 2023-02-17 00:53:07 +00:00
commit d084d81e35
3 changed files with 9 additions and 2 deletions

View File

@ -11,6 +11,7 @@
- Fix logical issue with uploading dynamic files ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/555))
- Fix backups failing by correctly using tz objects ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/556))
- Bump Cryptography/pyOpenSSL for CVE-2023-23931 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/554))
- Fix debug logging to only display with the -v (verbose) flag ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/560))
### Tweaks
- Cleanup authentication helpers ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/545))
- Optimize file upload progress WS ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/546))

View File

@ -19,6 +19,8 @@ except ModuleNotFoundError as ex:
class Console:
level = ""
def __init__(self):
if "colorama" in sys.modules:
init()
@ -61,6 +63,7 @@ class Console:
@staticmethod
def debug(message):
if Console.level == "debug":
date_time = Console.get_fmt_date_time()
Console.magenta(f"[+] Crafty: {date_time} - DEBUG:\t{message}")

View File

@ -102,6 +102,9 @@ if __name__ == "__main__":
setup_logging(debug=args.verbose)
if args.verbose:
Console.level = "debug"
# setting up the logger object
logger = logging.getLogger(__name__)
Console.cyan(f"Logging set to: {logger.level}")