-
Notifications
You must be signed in to change notification settings - Fork 99
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
added log config and replaced print with log #235
Changes from 1 commit
78cd8d6
eb38052
06c9a0a
f474808
cb25ffb
88a59b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,9 @@ | |
from pathlib import Path | ||
from typing import List, Tuple, Dict, Optional, Union | ||
|
||
# Configure the logging module | ||
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S') | ||
|
||
from google.auth.exceptions import MalformedError | ||
from google.cloud import container_v1 | ||
from google.cloud import iam_credentials | ||
|
@@ -166,7 +169,7 @@ def crawl_loop(initial_sa_tuples: List[Tuple[str, Credentials, List[str]]], | |
|
||
project_id = project['projectId'] | ||
project_number = project['projectNumber'] | ||
print(f'Inspecting project {project_id}') | ||
logging.info(f'Inspecting project {project_id}') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We actually want this to be printed in console so user understand what's going on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think using logging for everything makes sense here and have the default log level be info. The output is metadata about the process, not the result of the process itself. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Will there always be a logging file as part of the arguments? coz I was thinking if that file name is optional and not mandatory we can separate the logging as a filehandle for file logging and console handler for console printing something like this
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yea, probably that's how it should be. I was thinking about having INFO to be default but in some cases it is just a lot of data in terminal. IMO, it would be great to allow user to specify verbosity level instead of just ERROR, WARNING, INFO, with default (verbosity 0 or 1) to be minimum required to understand that scanner is working and scanning projects (probably print now) and maximum (e.g. 3) where we print everything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The log filename argument is optional. If it is set, we print in the file and if not the argument is None and it is simply console printing as far as I remember. |
||
project_result = sa_results['projects'][project_id] | ||
|
||
project_result['project_info'] = project | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have it already here:
gcp_scanner/src/gcp_scanner/scanner.py
Line 529 in b8c75d6