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

Turning off logger at the class-constructor level #323

Merged
merged 20 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
5 changes: 4 additions & 1 deletion src/core/zowe/core_for_zowe_sdk/sdk_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ class SdkApi:
Name of the logger (same as the filename by default)
"""

def __init__(self, profile: dict, default_url: str, logger_name: str = __name__):
def __init__(self, profile: dict, default_url: str, logger_name: str = __name__, log = True):
aadityasinha-dotcom marked this conversation as resolved.
Show resolved Hide resolved
session = Session(profile)
self.session: ISession = session.load()

self.logger = Log.register_logger(logger_name)

if log == False:
Log.close(self.logger)
aadityasinha-dotcom marked this conversation as resolved.
Show resolved Hide resolved

self._default_service_url = default_url
self._default_headers = {
"Content-Type": "application/json",
Expand Down
4 changes: 2 additions & 2 deletions src/zos_console/zowe/zos_console_for_zowe_sdk/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class Console(SdkApi):
A profile in dict (json) format
"""

def __init__(self, connection: dict):
super().__init__(connection, "/zosmf/restconsoles/consoles/defcn", logger_name=__name__)
def __init__(self, connection: dict, log = True):
super().__init__(connection, "/zosmf/restconsoles/consoles/defcn", logger_name=__name__, log=log)

def issue_command(self, command: str, console: Optional[str] = None) -> IssueCommandResponse:
"""Issues a command on z/OS Console.
Expand Down
2 changes: 1 addition & 1 deletion src/zos_files/zowe/zos_files_for_zowe_sdk/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class Datasets(SdkApi):
A profile for connection in dict (json) format
"""

def __init__(self, connection: dict):
def __init__(self, connection: dict, log = True):
super().__init__(connection, "/zosmf/restfiles/", logger_name=__name__)
aadityasinha-dotcom marked this conversation as resolved.
Show resolved Hide resolved
self._default_headers["Accept-Encoding"] = "gzip"

Expand Down
4 changes: 2 additions & 2 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class FileSystems(SdkApi):
A profile for connection in dict (json) format
"""

def __init__(self, connection: dict):
super().__init__(connection, "/zosmf/restfiles/", logger_name=__name__)
def __init__(self, connection: dict, log=True):
super().__init__(connection, "/zosmf/restfiles/", logger_name=__name__, log=log)
self._default_headers["Accept-Encoding"] = "gzip"

def create(self, file_system_name: str, options: dict = {}) -> dict:
Expand Down
4 changes: 2 additions & 2 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Files(SdkApi):
uss: USSFiles
fs: FileSystems

def __init__(self, connection: dict):
super().__init__(connection, "/zosmf/restfiles/", logger_name=__name__)
def __init__(self, connection: dict, log = True):
super().__init__(connection, "/zosmf/restfiles/", logger_name=__name__, log=log)
self._default_headers["Accept-Encoding"] = "gzip"
self.ds = Datasets(connection)
self.uss = USSFiles(connection)
Expand Down
2 changes: 1 addition & 1 deletion src/zos_files/zowe/zos_files_for_zowe_sdk/uss.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class USSFiles(SdkApi):
The z/OSMF connection object (generated by the ZoweSDK object)
"""

def __init__(self, connection: dict):
def __init__(self, connection: dict, log = True):
super().__init__(connection, "/zosmf/restfiles/", logger_name=__name__)
aadityasinha-dotcom marked this conversation as resolved.
Show resolved Hide resolved
self._default_headers["Accept-Encoding"] = "gzip"

Expand Down
4 changes: 2 additions & 2 deletions src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Jobs(SdkApi):
A profile for connection in dict (json) format
"""

def __init__(self, connection: dict):
super().__init__(connection, "/zosmf/restjobs/jobs/", logger_name=__name__)
def __init__(self, connection: dict, log = True):
super().__init__(connection, "/zosmf/restjobs/jobs/", logger_name=__name__, log=log)

def get_job_status(self, jobname: str, jobid: str) -> JobResponse:
"""
Expand Down
4 changes: 2 additions & 2 deletions src/zos_tso/zowe/zos_tso_for_zowe_sdk/tso.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Tso(SdkApi):
Profile used for tso connection
"""

def __init__(self, connection: dict, tso_profile: Optional[dict] = None):
super().__init__(connection, "/zosmf/tsoApp/tso", logger_name=__name__)
def __init__(self, connection: dict, tso_profile: Optional[dict] = None, log = True):
super().__init__(connection, "/zosmf/tsoApp/tso", logger_name=__name__, log=log)
self.session_not_found = constants["TsoSessionNotFound"]
self.tso_profile = tso_profile or {}

Expand Down
4 changes: 2 additions & 2 deletions src/zosmf/zowe/zosmf_for_zowe_sdk/zosmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class Zosmf(SdkApi):
The z/OSMF connection object (generated by the ZoweSDK object)
"""

def __init__(self, connection: dict):
super().__init__(connection, "/zosmf/info", logger_name=__name__)
def __init__(self, connection: dict, log = True):
super().__init__(connection, "/zosmf/info", logger_name=__name__, log=log)

def get_info(self) -> ZosmfResponse:
"""
Expand Down
Loading