-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
78 additions
and
44 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
File renamed without changes.
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,2 @@ | ||
from .gptlinter import main | ||
main() |
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
File renamed without changes.
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,18 @@ | ||
import logging | ||
from gpt_linter.singleton import Singleton | ||
class Logger(metaclass=Singleton): | ||
def __init__(self): | ||
self.logger= logging.getLogger(__name__) | ||
self.logger.propagate=False | ||
|
||
def setup_logger(self, debug: bool) -> None: | ||
self.logger.setLevel(logging.DEBUG if debug else logging.INFO) | ||
log_format = "%(levelname)s - %(message)s" | ||
formatter = logging.Formatter(log_format) | ||
ch = logging.StreamHandler() | ||
ch.setFormatter(formatter) | ||
self.logger.handlers = [ch] | ||
|
||
def __getattr__(self, attr): | ||
return getattr(self.logger, attr) | ||
|
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,24 @@ | ||
#Taken from autogpt | ||
"""The singleton metaclass for ensuring only one instance of a class.""" | ||
import abc | ||
|
||
|
||
class Singleton(abc.ABCMeta, type): | ||
""" | ||
Singleton metaclass for ensuring only one instance of a class. | ||
""" | ||
|
||
_instances = {} | ||
|
||
def __call__(cls, *args, **kwargs): | ||
"""Call method for the singleton metaclass.""" | ||
if cls not in cls._instances: | ||
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) | ||
return cls._instances[cls] | ||
|
||
|
||
class AbstractSingleton(abc.ABC, metaclass=Singleton): | ||
""" | ||
Abstract singleton class for ensuring only one instance of a class. | ||
""" | ||
|
This file was deleted.
Oops, something went wrong.
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