Skip to content

Instantly share code, notes, and snippets.

@SirmaXX
Last active July 1, 2023 06:01
Show Gist options
  • Save SirmaXX/4fe27d2489b14d5fd929020c2c9fab62 to your computer and use it in GitHub Desktop.
Save SirmaXX/4fe27d2489b14d5fd929020c2c9fab62 to your computer and use it in GitHub Desktop.
logging system with factory design pattern
class Log:
global date_time
now = datetime.now()
date_time = now.strftime("%m/%d/%Y, %H:%M:%S")
def __init__(self,severity,message,user):
self.severity=severity
self.message=message
self.time= date_time
def Debug(self):
print(self.time ,self.severity,self.message)
def PrintMessage(self):
print(self.message)
def Info(self,message):
record=Log("INFO",message)
record.Debug()
del record
class LogFactory(Log):
def Info(self,message,fun, *args):
record=Log("INFO::",message)
record.Debug()
fun(*args)
del record
def Warning(self,message):
record=Log("Warning::",message)
record.Debug()
del record
def Error(self,message):
record=Log("Error::",message)
record.Debug()
del record
def Critical(self,message):
record=Log("Critical::",message)
record.Debug()
del record
infodeneme=LogFactory()
infodeneme.Info("deneme fonk", deneme)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment