-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from zowe/logger
Adding logger modules
- Loading branch information
Showing
19 changed files
with
311 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import logging | ||
import os | ||
|
||
class Log: | ||
"""root logger setup and a function to customize logger level""" | ||
|
||
dirname = os.path.join(os.path.expanduser("~"), ".zowe/logs") | ||
|
||
os.makedirs(dirname, exist_ok=True) | ||
|
||
logging.basicConfig( | ||
filename=os.path.join(dirname, "python_sdk_logs.log"), | ||
level=logging.INFO, | ||
format="[%(asctime)s] [%(levelname)s] [%(name)s] - %(message)s", | ||
datefmt="%m/%d/%Y %I:%M:%S %p", | ||
) | ||
|
||
loggers = [] | ||
@staticmethod | ||
def registerLogger(name: str): | ||
"""A function to get Logger and registered for level setting""" | ||
logger = logging.getLogger(name) | ||
Log.loggers.append(logger) | ||
return logger | ||
|
||
@staticmethod | ||
def setLoggerLevel(level: int): | ||
for logger in Log.loggers: | ||
logger.setLevel(level) |
Oops, something went wrong.