-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Date filter, logging and types (#26)
* added logging, date filter and types Signed-off-by: Shashank Reddy Boyapally <[email protected]> * added types for constructor Signed-off-by: Shashank Reddy Boyapally <[email protected]> * add pull request to workflows, add new unit test Signed-off-by: Shashank Reddy Boyapally <[email protected]> * pylint error Signed-off-by: Shashank Reddy Boyapally <[email protected]> * bumped version Signed-off-by: Shashank Reddy Boyapally <[email protected]> * updated utility for functional testing Signed-off-by: Shashank Reddy Boyapally <[email protected]> --------- Signed-off-by: Shashank Reddy Boyapally <[email protected]>
- Loading branch information
1 parent
f715ad5
commit 69145e4
Showing
6 changed files
with
159 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
name: Run pytest on Pull Request | ||
|
||
on: [push] | ||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
|
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,49 @@ | ||
""" | ||
Logger as a common package | ||
""" | ||
|
||
import logging | ||
import sys | ||
|
||
|
||
class SingletonLogger: | ||
"""Singleton logger to set logging at one single place | ||
Returns: | ||
_type_: _description_ | ||
""" | ||
|
||
instance = {} | ||
|
||
def __new__(cls, debug: int, name: str): | ||
if (not cls.instance) or name not in cls.instance: | ||
cls.instance[name] = cls._initialize_logger(debug,name) | ||
return cls.instance[name] | ||
|
||
@staticmethod | ||
def _initialize_logger(debug: int, name: str) -> logging.Logger: | ||
level = debug # if debug else logging.INFO | ||
logger = logging.getLogger(name) | ||
logger.propagate=False | ||
if not logger.hasHandlers(): | ||
logger.setLevel(level) | ||
handler = logging.StreamHandler(sys.stdout) | ||
handler.setLevel(level) | ||
formatter = logging.Formatter( | ||
"%(asctime)s - %(name)-10s - %(levelname)s - file: %(filename)s - line: %(lineno)d - %(message)s" # pylint: disable = line-too-long | ||
) | ||
handler.setFormatter(formatter) | ||
logger.addHandler(handler) | ||
return logger | ||
|
||
@classmethod | ||
def getLogger(cls, name:str) -> logging.Logger: | ||
"""Return logger in instance | ||
Args: | ||
name (str): name of the logger | ||
Returns: | ||
logging.Logger: logger | ||
""" | ||
return cls.instance.get(name, None) |
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